protected function _createDocumentManager($metadataDriver) { $connMock = new ConnectionMock(); $config = new \Doctrine\ODM\MongoDB\Configuration(); $config->setProxyDir(__DIR__ . '/../../Proxies'); $config->setProxyNamespace('Doctrine\\ODM\\MongoDB\\Tests\\Proxies'); $config->setHydratorDir(__DIR__ . '/../../Hydrators'); $config->setHydratorNamespace('Doctrine\\ODM\\MongoDB\\Tests\\Hydrators'); $eventManager = new EventManager(); $mockDriver = new MetadataDriverMock(); $config->setMetadataDriverImpl($metadataDriver); return DocumentManagerMock::create($connMock, $config, $eventManager); }
protected function getTestDocumentManager($metadataDriver = null) { if ($metadataDriver === null) { $metadataDriver = new MetadataDriverMock(); } $mongoMock = new ConnectionMock(); $config = new \Doctrine\ODM\MongoDB\Configuration(); $config->setProxyDir(__DIR__ . '/../../Proxies'); $config->setProxyNamespace('Doctrine\ODM\MongoDB\Tests\Proxies'); $eventManager = new EventManager(); $mockDriver = new MetadataDriverMock(); $config->setMetadataDriverImpl($metadataDriver); return DocumentManagerMock::create($mongoMock, $config, $eventManager); }
protected function setUp() { parent::setUp(); $this->dm = DocumentManagerMock::create(new ConnectionMock()); $this->uow = $this->dm->getUnitOfWork(); }
protected function getDocumentManager() { $config = new Configuration(); $config->setProxyDir(__DIR__ . '/../../../../Proxies'); $config->setProxyNamespace('Proxies'); $config->setHydratorDir(__DIR__ . '/../../../../Hydrators'); $config->setHydratorNamespace('Hydrators'); $config->setDefaultDB('doctrine_odm_tests'); $reader = new AnnotationReader(); $config->setMetadataDriverImpl(new AnnotationDriver($reader, __DIR__ . '/../../../../Documents')); return DocumentManagerMock::create($this->getConnection(), $config); }
public function testPreUpdateTriggeredWithEmptyChangeset() { $dm = DocumentManagerMock::create(); $evm = $dm->getEventManager()->addEventSubscriber(new \Doctrine\ODM\MongoDB\Tests\Mocks\PreUpdateListenerMock()); $user = new \Documents\ForumUser(); $user->username = '******'; $dm->persist($user); $dm->flush(); $user->username = '******'; $dm->persist($user); $dm->flush(); }