I have a problem with composer autoload because autoloader cannot resolve Doctrine \ ORM \ Mapping \ Table. For Unittests, I created doctrine entity classes with typical annotations:
<?php namespace OmniSearchTest\Entity; use Doctrine\ORM\Mapping as ORM; class Picture {
and created a new entity manager using these entities. But I get the message:
Doctrine\Common\Annotations\AnnotationException: [Semantical Error] The annotation "@Doctrine\ORM\Mapping\Table" in class OmniSearchTest\Entity\Picture does not exist, or could not be auto-loaded.
For some Unittests
Firstly, I have the following project structure:
/src /OmniSearch SomeClass.php /tests /OmniSearchTest SomeClassTest.php /composer.json /phpunit.xml.dist
My composer.json looks like this:
{ "require": { "php": ">=5.4", "doctrine/orm": "2.*" }, "require-dev": { "phpunit/phpunit": "4.*" }, "autoload": { "psr-0": { "OmniSearch\\": "src/" } }, "autoload-dev": { "psr-0": { "OmniSearchTest\\": "tests/" } } }
So far my phpunit looks like this:
<?xml version="1.0" encoding="UTF-8"?> <phpunit backupGlobals="false" backupStaticAttributes="false" bootstrap="vendor/autoload.php" strict="true" verbose="true"> <testsuites> <testsuite name="omnisearch"> <directory>./tests/OmniSearchTest</directory> </testsuite> </testsuites> </phpunit>
I disconnected this project from another zf2 project where autoload worked fine. I'm not sure what exactly went wrong, because autoload_namespaces.php autogeneration contains a mapping:
'Doctrine\\ORM\\' => array($vendorDir . '/doctrine/orm/lib'),