Esempio n. 1
0
 /**
  * @param string $entityType
  * @param object $entity
  * @return object
  * @throws \Exception
  */
 public function execute($entityType, $entity)
 {
     $entity = $this->createMain->execute($entityType, $entity);
     $entity = $this->createExtension->execute($entityType, $entity);
     $entity = $this->createRelation->execute($entityType, $entity);
     return $entity;
 }
Esempio n. 2
0
 public function testExecute()
 {
     $entityType = 'SomeNameSpace\\SomeClassName';
     $entity = ['name' => 'test'];
     $entityWithMainCreate = array_merge($entity, ['main' => 'info']);
     $this->createMainMock->expects($this->once())->method('execute')->with($entityType, $entity)->willReturn($entityWithMainCreate);
     $entityWithExtensions = array_merge($entityWithMainCreate, ['ext' => 'extInfo']);
     $this->createExtensionMock->expects($this->once())->method('execute')->with($entityType, $entityWithMainCreate)->willReturn($entityWithExtensions);
     $entityWithRelations = array_merge($entityWithExtensions, ['relations' => 'info']);
     $this->createRelationMock->expects($this->once())->method('execute')->with($entityType, $entityWithExtensions)->willReturn($entityWithRelations);
     $this->assertEquals($entityWithRelations, $this->create->execute($entityType, $entity));
 }
Esempio n. 3
0
 public function testExecute()
 {
     $entityType = 'Type';
     $entity = new \stdClass();
     $entityData = ['name' => 'test'];
     $entityHydrator = $this->getMockBuilder(EntityHydrator::class)->disableOriginalConstructor()->getMock();
     $action = $this->getMockBuilder(\stdClass::class)->disableOriginalConstructor()->setMethods(['execute'])->getMock();
     $this->metadataPoolMock->expects($this->once())->method('getHydrator')->willReturn($entityHydrator);
     $entityHydrator->expects($this->once())->method('extract')->with($entity)->willReturn([]);
     $this->extensionPoolMock->expects($this->once())->method('getActions')->with($entityType, 'create')->willReturn([$action]);
     $action->expects($this->once())->method('execute')->with($entityType, $entityData)->willReturn($entityData);
     $entityHydrator->expects($this->once())->method('hydrate')->with($entity, $entityData)->willReturn($entity);
     $this->assertEquals($entity, $this->createExtension->execute($entityType, $entity, $entityData));
 }