Ejemplo n.º 1
0
 public function testFind_DocumentIsKnown()
 {
     $document = new Document();
     $document->addField('id', 2);
     $document->addField('document_name_s', 'post');
     $metaFactory = $this->getMock('FS\\SolrBundle\\Doctrine\\Mapper\\MetaInformationFactory', array(), array(), '', false);
     $metaFactory->expects($this->once())->method('loadInformation')->will($this->returnValue(MetaTestInformationFactory::getMetaInformation()));
     $mapper = $this->getMock('FS\\SolrBundle\\Doctrine\\Mapper\\EntityMapper', array(), array(), '', false);
     $mapper->expects($this->once())->method('toDocument')->will($this->returnValue($document));
     $solr = $this->getMock('FS\\SolrBundle\\Solr', array(), array(), '', false);
     $solr->expects($this->exactly(2))->method('getMapper')->will($this->returnValue($mapper));
     $solr->expects($this->once())->method('getCommandFactory')->will($this->returnValue(CommandFactoryStub::getFactoryWithAllMappingCommand()));
     $solr->expects($this->once())->method('getMetaFactory')->will($this->returnValue($metaFactory));
     $entity = new ValidTestEntity();
     $solr->expects($this->once())->method('query')->will($this->returnValue(array($entity)));
     $repo = new Repository($solr, $entity);
     $actual = $repo->find(2);
     $this->assertTrue($actual instanceof ValidTestEntity, 'find return no entity');
 }