Optimized test for ActionFactoryService

This commit is contained in:
Kevin Frantz 2019-01-27 17:57:34 +01:00
parent 2ed83ab284
commit 0593a8f1c3

View File

@ -10,7 +10,8 @@ use App\Domain\ActionManagement\ActionServiceInterface;
use App\DBAL\Types\ActionType; use App\DBAL\Types\ActionType;
use App\Domain\ActionManagement\ActionInterface; use App\Domain\ActionManagement\ActionInterface;
use App\Domain\RequestManagement\Action\RequestedActionInterface; use App\Domain\RequestManagement\Action\RequestedActionInterface;
use App\Domain\RequestManagement\Entity\RequestedEntityInterface; use App\Domain\RequestManagement\Action\RequestedAction;
use App\Domain\RequestManagement\Right\RequestedRightInterface;
/** /**
* @author kevinfrantz * @author kevinfrantz
@ -34,21 +35,22 @@ class ActionFactoryServiceTest extends TestCase
public function setUp(): void public function setUp(): void
{ {
$this->requestedEntity = $this->createMock(RequestedEntityInterface::class); $requestedRight = $this->createMock(RequestedRightInterface::class);
$this->requestedAction = $this->createMock(RequestedActionInterface::class); $this->requestedAction = new RequestedAction($requestedRight);
$this->actionService = $this->createMock(ActionServiceInterface::class); $this->actionService = $this->createMock(ActionServiceInterface::class);
$this->actionService->method('getRequestedAction')->willReturn($this->requestedAction); $this->actionService->method('getRequestedAction')->willReturn($this->requestedAction);
$this->actionFactoryService = new ActionFactoryService($this->actionService); $this->actionFactoryService = new ActionFactoryService($this->actionService);
} }
public function testCreate(): void public function testCreate(): void
{ {
foreach (ActionType::getChoices() as $action) { foreach (ActionType::getChoices() as $action) {
foreach (LayerType::getChoices() as $layer) { foreach (LayerType::getChoices() as $layer) {
$this->requestedAction->method('getLayer')->willReturn($layer); $this->requestedAction->setLayer($layer);
$this->requestedAction->method('getActionType')->willReturn($action); $this->requestedAction->setActionType($action);
$action = $this->actionFactoryService->create(); $result = $this->actionFactoryService->create();
$this->assertInstanceOf(ActionInterface::class, $action); $this->assertInstanceOf(ActionInterface::class, $result);
} }
} }
} }