public function testRevertIndexComposite()
 {
     $self = $this;
     $registry = $this->getMock('Doctrine\\Common\\Persistence\\ManagerRegistry');
     $registry->expects($this->any())->method('getManagerForClass')->will($this->returnCallback(function () use($self) {
         $metadataFactory = $self->getMock('Doctrine\\ORM\\Mapping\\ClassMetadataFactory');
         $metadataFactory->expects($self->any())->method('getMetadataFor')->will($self->returnCallback(function () use($self) {
             $classMetadata = $self->getMockBuilder('Doctrine\\ORM\\Mapping\\ClassMetadata')->disableOriginalConstructor()->getMock();
             $classMetadata->expects($self->any())->method('getIdentifierFieldNames')->will($self->returnValue(array('id', 'name')));
             return $classMetadata;
         }));
         $em = new EntityManagerMock();
         $em->_setMetadataFactory($metadataFactory);
         return $em;
     }));
     $strategy = new EntityIndexingStrategy($registry);
     foreach (array('_', '|') as $separator) {
         $index = '1' . $separator . 'Foo';
         $strategy->setSeparator($separator);
         $this->assertSame(array('id' => '1', 'name' => 'Foo'), $strategy->revertIndex($index, 'Entity'));
     }
 }
示例#2
0
 protected function getManagerRegistry()
 {
     $self = $this;
     $managerRegistry = $this->getMock("Doctrine\\Common\\Persistence\\ManagerRegistry");
     $managerRegistry->expects($this->any())->method('getManagerForClass')->will($this->returnCallback(function () use($self) {
         $manager = $self->getMock("Doctrine\\Common\\Persistence\\ObjectManager");
         $manager->expects($self->any())->method('getMetadataFactory')->will($self->returnCallback(function () use($self) {
             $metadataFactory = $self->getMock("Doctrine\\Common\\Persistence\\Mapping\\ClassMetadataFactory");
             $metadataFactory->expects($self->any())->method('getMetadataFor')->will($self->returnCallback(function ($class) use($self) {
                 switch ($class) {
                     case "FSi\\Component\\DataGrid\\Tests\\Fixtures\\EntityTree":
                         $metadata = $self->getMock('Doctrine\\ORM\\Mapping\\ClassMetadataInfo', array(), array($class));
                         $metadata->expects($self->any())->method('getIdentifierFieldNames')->will($self->returnValue(array('id')));
                         break;
                 }
                 return $metadata;
             }));
             $metadataFactory->expects($self->any())->method('getClassMetadata')->will($self->returnCallback(function ($class) {
                 return $metadataFactory->getMetadataFor($class);
             }));
             return $metadataFactory;
         }));
         $manager->expects($self->any())->method('getClassMetadata')->will($self->returnCallback(function ($class) use($self) {
             switch ($class) {
                 case "FSi\\Component\\DataGrid\\Tests\\Fixtures\\EntityTree":
                     $metadata = $self->getMock('Doctrine\\ORM\\Mapping\\ClassMetadataInfo', array(), array($class));
                     $metadata->expects($self->any())->method('getIdentifierFieldNames')->will($self->returnValue(array('id')));
                     $metadata->isMappedSuperclass = false;
                     $metadata->rootEntityName = $class;
                     break;
             }
             return $metadata;
         }));
         return $manager;
     }));
     $treeListener = $this->getMock('Gedmo\\Tree\\TreeListener');
     $strategy = $this->getMock('Gedmo\\Tree\\Strategy');
     $treeListener->expects($this->once())->method('getStrategy')->will($this->returnValue($strategy));
     $treeListener->expects($this->once())->method('getConfiguration')->will($this->returnValue(array('left' => 'left', 'right' => 'right', 'root' => 'root', 'level' => 'level', 'parent' => 'parent')));
     $strategy->expects($this->once())->method('getName')->will($this->returnValue('nested'));
     $evm = new EventManagerMock(array($treeListener));
     $em = new EntityManagerMock();
     $em->_setEventManager($evm);
     $managerRegistry->expects($this->any())->method('getManager')->will($this->returnValue($em));
     return $managerRegistry;
 }