Renamed domain ActionManagement to Action

This commit is contained in:
Kevin Frantz
2019-05-30 16:03:44 +02:00
parent d2b0cba30b
commit 123df1147a
36 changed files with 112 additions and 112 deletions

View File

@@ -0,0 +1,57 @@
<?php
namespace tests\Unit\Domain\Action\Read;
use PHPUnit\Framework\TestCase;
use Infinito\Domain\Action\ActionInterface;
use Infinito\Domain\Action\AbstractAction;
use Infinito\Domain\Action\ActionDependenciesDAOServiceInterface;
use PHPUnit\Framework\MockObject\MockObject;
use Infinito\Exception\Validation\FormInvalidException;
/**
* @author kevinfrantz
*/
class AbstractActionTest extends TestCase
{
/**
* @var ActionInterface
*/
private $action;
/**
* @var ActionDependenciesDAOServiceInterface|MockObject
*/
private $actionService;
public function setUp(): void
{
$this->actionService = $this->createMock(ActionDependenciesDAOServiceInterface::class);
$this->action = new class($this->actionService) extends AbstractAction {
public $isSecure;
public $validByForm;
protected function isSecure(): bool
{
return $this->isSecure;
}
protected function isValid(): bool
{
return $this->validByForm;
}
protected function proccess()
{
}
};
}
public function testNotValidByFormException(): void
{
$this->action->isSecure = true;
$this->action->validByForm = false;
$this->expectException(FormInvalidException::class);
$this->action->execute();
}
}

View File

@@ -0,0 +1,72 @@
<?php
namespace tests\Unit\Domain\SecureCRUDManagement\CRUD\Read;
use Doctrine\ORM\EntityManagerInterface;
use PHPUnit\Framework\TestCase;
use Infinito\Domain\Action\Read\ReadAction;
use Infinito\Domain\Action\ActionDependenciesDAOServiceInterface;
use Infinito\Domain\Action\Read\ReadActionInterface;
use Infinito\Domain\RequestManagement\Action\RequestedActionInterface;
use Infinito\Domain\RequestManagement\Entity\RequestedEntityInterface;
use Infinito\Entity\Source\SourceInterface;
use Infinito\Exception\Permission\NoPermissionException;
/**
* @author kevinfrantz
*/
class ReadSourceActionTest extends TestCase
{
/**
* @var EntityManagerInterface
*/
private $entityManager;
/**
* @var ActionDependenciesDAOServiceInterface
*/
private $actionService;
/**
* @var ReadActionInterface
*/
private $sourceReadAction;
/**
* @var RequestedEntityInterface
*/
private $requestedEntity;
/**
* @var SourceInterface
*/
private $entity;
public function setUp(): void
{
$this->entity = $this->createMock(SourceInterface::class);
$this->requestedEntity = $this->createMock(RequestedEntityInterface::class);
$this->requestedEntity->method('getEntity')->willReturn($this->entity);
$this->entityManager = $this->createMock(EntityManagerInterface::class);
$this->requestedAction = $this->createMock(RequestedActionInterface::class);
$this->requestedAction->method('getRequestedEntity')->willReturn($this->requestedEntity);
$this->actionService = $this->createMock(ActionDependenciesDAOServiceInterface::class);
$this->actionService->method('getEntityManager')->willReturn($this->entityManager);
$this->actionService->method('getRequestedAction')->willReturn($this->requestedAction);
$this->sourceReadAction = new ReadAction($this->actionService);
}
public function testNotSecureException(): void
{
$this->actionService->method('isRequestedActionSecure')->willReturn(false);
$this->expectException(NoPermissionException::class);
$this->sourceReadAction->execute();
}
public function testGranted(): void
{
$this->actionService->method('isRequestedActionSecure')->willReturn(true);
$result = $this->sourceReadAction->execute();
$this->assertEquals($this->entity, $result);
}
}