0
I installed Doctrine via Poser:
{
"require": {
"doctrine/common": "2.4.*",
"doctrine/dbal": "2.4.*",
"doctrine/orm": "2.4.*",
"phpunit/phpunit": "3.7.*"
}
}
When running unit tests, the file location ArrayCollection
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 believe the problem is related to the folder structure generated by Composer.
Is the folder structure that Poser set up for Doctrine wrong? How to fix?
I released the code on gitlab.
I’m using php 5.4.30.
I copied your Composer.json and installed the packages here, there was no error executing the phpunit command. Try to delete the vendor folder and the Composer.lock file and have it installed again.
– Adir Kuhn
tries to download the git I shared. When running your guidelines, the same error appeared. The problem occurs in the USER class qd tries to instantiate an arraycollecction
– Israel Zebulon