infinito/application/symfony/tests/Unit/Domain/ActionManagement/ActionServiceTest.php

77 lines
2.4 KiB
PHP
Raw Normal View History

2019-01-27 09:35:43 +01:00
<?php
namespace tests\Unit\Domain\ActionManagement;
use PHPUnit\Framework\TestCase;
use App\Domain\ActionManagement\ActionService;
use App\Domain\RequestManagement\Action\RequestedActionInterface;
use App\Domain\SecureManagement\SecureRequestedRightCheckerInterface;
2019-01-27 15:28:25 +01:00
use Doctrine\ORM\EntityManagerInterface;
use App\Domain\FormManagement\EntityFormBuilderServiceInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use App\Domain\RepositoryManagement\LayerRepositoryFactoryServiceInterface;
use App\Domain\ActionManagement\ActionServiceInterface;
2019-01-27 09:35:43 +01:00
/**
* @author kevinfrantz
*/
class ActionServiceTest extends TestCase
{
2019-01-27 15:28:25 +01:00
/**
* @var RequestedActionInterface
*/
private $requestedAction;
/**
* @var SecureRequestedRightCheckerInterface
*/
private $secureRequestedRightChecker;
/**
* @var EntityFormBuilderServiceInterface
*/
private $entityFormBuilderService;
/**
* @var RequestStack
*/
private $requestStack;
/**
* @var LayerRepositoryFactoryServiceInterface
*/
private $layerRepositoryFactoryService;
/**
* @var ActionServiceInterface
*/
private $actionService;
/**
* @var EntityManagerInterface
*/
private $entityManager;
public function setUp(): void
{
$this->requestedAction = $this->createMock(RequestedActionInterface::class);
$this->secureRequestedRightChecker = $this->createMock(SecureRequestedRightCheckerInterface::class);
$this->entityFormBuilderService = $this->createMock(EntityFormBuilderServiceInterface::class);
$this->requestStack = $this->createMock(RequestStack::class);
$this->layerRepositoryFactoryService = $this->createMock(LayerRepositoryFactoryServiceInterface::class);
$this->entityManager = $this->createMock(EntityManagerInterface::class);
$this->actionService = new ActionService($this->requestedAction, $this->secureRequestedRightChecker, $this->requestStack, $this->layerRepositoryFactoryService, $this->entityFormBuilderService, $this->entityManager);
}
2019-01-27 09:35:43 +01:00
public function testIsRequestedActionSecure()
{
2019-01-27 15:28:25 +01:00
$this->secureRequestedRightChecker->method('check')->willReturn(true);
$this->assertTrue($this->actionService->isRequestedActionSecure());
2019-01-27 09:35:43 +01:00
}
public function testRequestedActionGetter()
{
2019-01-27 15:28:25 +01:00
$this->assertInstanceOf(RequestedActionInterface::class, $this->actionService->getRequestedAction());
2019-01-27 09:35:43 +01:00
}
}