public function setUp() { $this->metaFactory = $metaFactory = $this->getMock('FS\\SolrBundle\\Doctrine\\Mapper\\MetaInformationFactory', array(), array(), '', false); $this->config = $this->getMock('FS\\SolrBundle\\SolrConnection', array(), array(), '', false); $this->commandFactory = CommandFactoryStub::getFactoryWithAllMappingCommand(); $this->eventDispatcher = $this->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcher', array(), array(), '', false); $this->mapper = $this->getMock('FS\\SolrBundle\\Doctrine\\Mapper\\EntityMapper', array(), array(), '', false); $this->solrClientFake = $this->getMock('Solarium\\Client', array(), array(), '', false); }
public function setUp() { $this->metaFactory = $metaFactory = $this->getMock('FS\\SolrBundle\\Doctrine\\Mapper\\MetaInformationFactory', array(), array(), '', false); $this->config = $this->getMock('FS\\SolrBundle\\SolrConnection', array(), array(), '', false); $this->commandFactory = CommandFactoryStub::getFactoryWithAllMappingCommand(); $this->eventManager = $this->getMock('FS\\SolrBundle\\Event\\EventManager', array(), array(), '', false); $this->connectionFactory = $this->getMock('FS\\SolrBundle\\SolrConnectionFactory', array(), array(), '', false); $this->solrClientFake = new SolrClientFake(); $this->config->expects($this->once())->method('getClient')->will($this->returnValue($this->solrClientFake)); $this->connectionFactory->expects($this->any())->method('getDefaultConnection')->will($this->returnValue($this->config)); }
public function testFindAll() { $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->findAll(); $this->assertTrue(is_array($actual)); $this->assertNull($document->id, 'id was removed'); }