public function testToEntity_ConcreteDocumentClass_WithDoctrine() { $targetEntity = new ValidTestEntity(); $this->indexHydrator->expects($this->once())->method('hydrate')->will($this->returnValue($targetEntity)); $this->doctrineHydrator->expects($this->once())->method('hydrate')->will($this->returnValue($targetEntity)); $mapper = new \FS\SolrBundle\Doctrine\Mapper\EntityMapper($this->doctrineHydrator, $this->indexHydrator, $this->metaInformationFactory); $mapper->setHydrationMode(HydrationModes::HYDRATE_DOCTRINE); $entity = $mapper->toEntity(new Document(array()), $targetEntity); $this->assertTrue($entity instanceof $targetEntity); }
public function testToEntity() { $obj = new SolrDocumentStub(array('id' => 1, 'title_t' => 'foo')); $targetEntity = new ValidTestEntity(); $mapper = new \FS\SolrBundle\Doctrine\Mapper\EntityMapper(); $entity = $mapper->toEntity($obj, $targetEntity); $this->assertTrue($entity instanceof $targetEntity); $this->assertEquals(1, $entity->getId()); $this->assertEquals('foo', $entity->getTitle()); }
/** * @param MetaInformation metaInformationsy * @return \SolrInputDocument|null */ private function toDocument(MetaInformation $metaInformation) { $command = $this->commandFactory->get('all'); $this->entityMapper->setMappingCommand($command); $doc = $this->entityMapper->toDocument($metaInformation); return $doc; }