/** * @param string $entityType * @param object $entity * @return object * @throws \Exception */ public function execute($entityType, $entity) { $entity = $this->updateMain->execute($entityType, $entity); $entity = $this->updateExtension->execute($entityType, $entity); $entity = $this->updateRelation->execute($entityType, $entity); return $entity; }
public function testExecute() { $entityType = 'SomeNameSpace\\SomeClassName'; $entity = ['name' => 'test']; $entityWithMainCreate = array_merge($entity, ['main' => 'info']); $this->updateMainMock->expects($this->once())->method('execute')->with($entityType, $entity)->willReturn($entityWithMainCreate); $entityWithExtensions = array_merge($entityWithMainCreate, ['ext' => 'extInfo']); $this->updateExtensionMock->expects($this->once())->method('execute')->with($entityType, $entityWithMainCreate)->willReturn($entityWithExtensions); $entityWithRelations = array_merge($entityWithExtensions, ['relations' => 'info']); $this->updateRelationMock->expects($this->once())->method('execute')->with($entityType, $entityWithExtensions)->willReturn($entityWithRelations); $this->assertEquals($entityWithRelations, $this->update->execute($entityType, $entity)); }
public function testExecute() { $entityType = 'Type'; $entity = new \stdClass(); $entityData = ['name' => 'test']; $entityHydrator = $this->getMockBuilder(EntityHydrator::class)->disableOriginalConstructor()->getMock(); $this->metadataPoolMock->expects($this->once())->method('getHydrator')->willReturn($entityHydrator); $entityHydrator->expects($this->once())->method('extract')->with($entity)->willReturn([]); $entityHydrator->expects($this->once())->method('hydrate')->with($entity, $entityData)->willReturn($entity); $this->updateEntityRowMock->expects($this->once())->method('execute')->with($entityType, $entityData)->willReturn($entityData); $this->assertEquals($entity, $this->updateMain->execute($entityType, $entity, $entityData)); }