2019-01-27 15:28:25 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace tests\Unit\Domain\SecureCRUDManagement\Factory;
|
|
|
|
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
use App\Domain\ActionManagement\ActionFactoryServiceInterface;
|
|
|
|
use App\Domain\ActionManagement\ActionFactoryService;
|
|
|
|
use App\Domain\ActionManagement\ActionServiceInterface;
|
|
|
|
use App\Domain\ActionManagement\ActionInterface;
|
|
|
|
use App\Domain\RequestManagement\Action\RequestedActionInterface;
|
2019-01-27 17:57:34 +01:00
|
|
|
use App\Domain\RequestManagement\Action\RequestedAction;
|
2019-01-27 18:38:21 +01:00
|
|
|
use App\Domain\RequestManagement\Right\RequestedRight;
|
2019-01-27 20:28:31 +01:00
|
|
|
use App\Domain\LayerManagement\LayerActionMap;
|
2019-01-27 15:28:25 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @author kevinfrantz
|
|
|
|
*/
|
|
|
|
class ActionFactoryServiceTest extends TestCase
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var ActionFactoryServiceInterface
|
|
|
|
*/
|
|
|
|
private $actionFactoryService;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var ActionServiceInterface
|
|
|
|
*/
|
|
|
|
private $actionService;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var RequestedActionInterface
|
|
|
|
*/
|
|
|
|
private $requestedAction;
|
|
|
|
|
|
|
|
public function setUp(): void
|
|
|
|
{
|
2019-01-27 18:38:21 +01:00
|
|
|
$requestedRight = new RequestedRight();
|
2019-01-27 17:57:34 +01:00
|
|
|
$this->requestedAction = new RequestedAction($requestedRight);
|
2019-01-27 15:28:25 +01:00
|
|
|
$this->actionService = $this->createMock(ActionServiceInterface::class);
|
|
|
|
$this->actionService->method('getRequestedAction')->willReturn($this->requestedAction);
|
|
|
|
$this->actionFactoryService = new ActionFactoryService($this->actionService);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testCreate(): void
|
|
|
|
{
|
2019-01-27 20:28:31 +01:00
|
|
|
foreach (LayerActionMap::LAYER_ACTION_MAP as $layer => $actions) {
|
|
|
|
foreach ($actions as $action) {
|
2019-01-27 17:57:34 +01:00
|
|
|
$this->requestedAction->setLayer($layer);
|
|
|
|
$this->requestedAction->setActionType($action);
|
|
|
|
$result = $this->actionFactoryService->create();
|
|
|
|
$this->assertInstanceOf(ActionInterface::class, $result);
|
2019-01-27 15:28:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|