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);
 }
예제 #2
0
    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);
    }
예제 #3
0
 protected function setUp()
 {
     parent::setUp();
     $this->dm = DocumentManagerMock::create(new ConnectionMock());
     $this->uow = $this->dm->getUnitOfWork();
 }
 public function testGetDocumentCollectionAppliesClassMetadataSlaveOkay()
 {
     $cm1 = new ClassMetadataInfo('a');
     $cm1->collection = 'a';
     $cm2 = new ClassMetadataInfo('b');
     $cm2->collection = 'b';
     $cm2->slaveOkay = true;
     $cm3 = new ClassMetadataInfo('c');
     $cm3->collection = 'c';
     $cm3->slaveOkay = false;
     $map = array(array('a', $cm1), array('b', $cm2), array('c', $cm3));
     $metadataFactory = $this->getMockClassMetadataFactory();
     $metadataFactory->expects($this->any())->method('getMetadataFor')->will($this->returnValueMap($map));
     $coll1 = $this->getMockCollection();
     $coll1->expects($this->never())->method('setSlaveOkay');
     $coll2 = $this->getMockCollection();
     $coll2->expects($this->once())->method('setSlaveOkay')->with(true);
     $coll3 = $this->getMockCollection();
     $coll3->expects($this->once())->method('setSlaveOkay')->with(false);
     $dm = new DocumentManagerMock();
     $dm->metadataFactory = $metadataFactory;
     $dm->documentCollections = array('a' => $coll1, 'b' => $coll2, 'c' => $coll3);
     $dm->getDocumentCollection('a');
     $dm->getDocumentCollection('b');
     $dm->getDocumentCollection('c');
 }
 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);
 }
예제 #6
0
 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();
 }