/** * {@inheritdoc} */ public function execute($entityType, $entity, $identifier) { $metadata = $this->metadataPool->getMetadata($entityType); $entity = $this->readMain->execute($entityType, $entity, $identifier); if (isset($entity[$metadata->getLinkField()])) { $entity = $this->readExtension->execute($entityType, $entity); $entity = $this->readRelation->execute($entityType, $entity); } return $entity; }
public function testExecute() { $entityType = 'Type'; $entity = new \stdClass(); $entityData = ['name' => 'test']; $id = 1; $entityHydrator = $this->getMockBuilder(EntityHydrator::class)->disableOriginalConstructor()->getMock(); $this->metadataPoolMock->expects($this->once())->method('getHydrator')->willReturn($entityHydrator); $entityHydrator->expects($this->once())->method('hydrate')->with($entity, $entityData)->willReturn($entity); $this->readEntityRowMock->expects($this->once())->method('execute')->with($entityType, $id)->willReturn($entityData); $this->assertEquals($entity, $this->readMain->execute($entityType, $entity, $id)); }