/** * @param string $entityType * @param object $entity * @return true * @throws \Exception */ public function execute($entityType, $entity) { $this->deleteRelation->execute($entityType, $entity); $this->deleteExtension->execute($entityType, $entity); $this->deleteMain->execute($entityType, $entity); return true; }
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(); $entityMetadata = $this->getMockBuilder(EntityMetadata::class)->disableOriginalConstructor()->getMock(); $this->metadataPoolMock->expects($this->once())->method('getHydrator')->willReturn($entityHydrator); $this->metadataPoolMock->expects($this->once())->method('getMetadata')->willReturn($entityMetadata); $entityMetadata->expects($this->once())->method('getEavEntityType')->willReturn(true); $entityHydrator->expects($this->once())->method('extract')->with($entity)->willReturn([]); $this->extensionPoolMock->expects($this->once())->method('getActions')->with($entityType, 'delete')->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->deleteExtension->execute($entityType, $entity, $entityData)); }