I installed Doctrine via composer:
{
"require": {
"doctrine/common": "2.4.*",
"doctrine/dbal": "2.4.*",
"doctrine/orm": "2.4.*",
"phpunit/phpunit": "3.7.*"
}
}
When running unit tests, the location of the ArrayCollection
file was not found by namespace .
./vendor/bin/phpunit
Error presented:
Fatal error: Class 'DoctrineNaPratica \ Model \ ArrayCollection' not found in /Users/israel/Sites/doctrine/src/DoctrineNaPratica/Model/User.php on line 183
Fatal error: Class 'DoctrineNaPratica \ Model \ ArrayCollection' not found in /Users/israel/Sites/doctrine/src/DoctrineNaPratica/Model/User.php on line 183
This line 183 has the following code:
public function __construct()
{
$this->courseCollection = new ArrayCollection;
$this->lessonCollection = new ArrayCollection;
$this->profileCollection = new ArrayCollection;
$this->enrollmentCollection = new ArrayCollection;
}
And the Collection is declared via annotations :
/**
* @ORM\OneToMany(targetEntity="Course", mappedBy="teacher", cascade={"all"}, orphanRemoval=true, fetch="LAZY")
*
* @var Doctrine\Common\Collections\Collection
*/
protected $courseCollection;
I think the problem is related to the folder structure generated by the composer.
Is the folder structure the composer set up for the doctrine wrong? How do I fix it?
I made the code available in gitlab .
I'm using php 5.4.30.