2019-01-27 16:24:57 +01:00
|
|
|
<?php
|
|
|
|
|
2019-05-30 16:03:44 +02:00
|
|
|
namespace tests\Unit\Domain\Action\Read;
|
2019-01-27 16:24:57 +01:00
|
|
|
|
2019-05-30 16:03:44 +02:00
|
|
|
use Infinito\Domain\Action\AbstractAction;
|
|
|
|
use Infinito\Domain\Action\ActionDependenciesDAOServiceInterface;
|
2020-04-02 21:13:35 +02:00
|
|
|
use Infinito\Domain\Action\ActionInterface;
|
2019-04-15 01:37:17 +02:00
|
|
|
use Infinito\Exception\Validation\FormInvalidException;
|
2020-04-02 21:13:35 +02:00
|
|
|
use PHPUnit\Framework\MockObject\MockObject;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
2019-01-27 16:24:57 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @author kevinfrantz
|
|
|
|
*/
|
|
|
|
class AbstractActionTest extends TestCase
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var ActionInterface
|
|
|
|
*/
|
|
|
|
private $action;
|
|
|
|
|
|
|
|
/**
|
2019-04-14 14:28:08 +02:00
|
|
|
* @var ActionDependenciesDAOServiceInterface|MockObject
|
2019-01-27 16:24:57 +01:00
|
|
|
*/
|
|
|
|
private $actionService;
|
|
|
|
|
|
|
|
public function setUp(): void
|
|
|
|
{
|
2019-04-14 14:28:08 +02:00
|
|
|
$this->actionService = $this->createMock(ActionDependenciesDAOServiceInterface::class);
|
2019-01-27 16:24:57 +01:00
|
|
|
$this->action = new class($this->actionService) extends AbstractAction {
|
|
|
|
public $isSecure;
|
|
|
|
public $validByForm;
|
|
|
|
|
|
|
|
protected function isSecure(): bool
|
|
|
|
{
|
|
|
|
return $this->isSecure;
|
|
|
|
}
|
|
|
|
|
2019-02-12 16:47:37 +01:00
|
|
|
protected function isValid(): bool
|
2019-01-27 16:24:57 +01:00
|
|
|
{
|
|
|
|
return $this->validByForm;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function proccess()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testNotValidByFormException(): void
|
|
|
|
{
|
|
|
|
$this->action->isSecure = true;
|
|
|
|
$this->action->validByForm = false;
|
2019-04-15 01:37:17 +02:00
|
|
|
$this->expectException(FormInvalidException::class);
|
2019-01-27 16:24:57 +01:00
|
|
|
$this->action->execute();
|
|
|
|
}
|
|
|
|
}
|