コード例 #1
0
 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');
 }