I have the following situation:
A ZF2 driven application which uses Doctrine for the database related stuff.
My directory layout is that of a typical ZF2 application, except that my module directory (the one that contains src) has a sub-directory test with a seperate module for testing the module in the parent folder.
├───MyModule
│ ├───config
│ ├───src
│ │ └───MyModule
│ │ ├───Controller
│ │ ├───DoctrineExtensions
│ │ ├───Entity
│ │ ├───Factory
│ │ │ └───ViewHelper
│ │ ├───Fieldset
│ │ ├───Filter
│ │ ├───Form
│ │ │ └───Element
│ │ ├───Helper
│ │ ├───Hydrator
│ │ │ └───Strategy
│ │ ├───Mail
│ │ ├───Model
│ │ ├───Service
│ │ ├───Traits
│ │ ├───Validator
│ │ └───View
│ │ └───Helper
│ ├───test
│ │ ├───doc
│ │ └───MyModuleTest
│ │ ├───data
│ │ │ ├───DoctrineORMModule
│ │ │ │ └───Proxy
│ │ │ └───sql
│ │ │ └───data_single
│ │ ├───Fixture
│ │ └───Service
│ └───view
│ ├───flash-messenger
│ └───partial
I want to use a seperate Doctrine configuration and DB connection so I set it up according to DoctrineORMModule documentation.
In the Bootstrap.php file I use for setting up loading the modules under test (gets loaded by PHPUnit before every test run) I set up the ZF2`s ServiceManager and load the Doctrine configuration.
static::$config = $config; // contains merged config
$serviceManager = new ServiceManager(new ServiceManagerConfig());
$serviceManager->setService('ApplicationConfig', $config);
$serviceManager->setFactory('ServiceListener', 'Zend\Mvc\Service\ServiceListenerFactory');
But when I try to get the entity manager
$em = $serviceManager->get('doctrine.entitymanager.orm_testing_mysql');
I always get a
RuntimeException: Options with name "orm_testing_mysql" could not be found in "doctrine.entitymanager"
Running my debugger I found out that $serviceManage->instances['applicationconfig'] contains all the arrays I defined in my configuration file.
$serviceManage->instances['config']['doctrine'] however only contains the default doctrine configuration / connection data shipped with the module.
Can someone figure out what's going wrong? Any help would be appreciated..