2019-01-12 15:40:54 +01:00
|
|
|
<?php
|
|
|
|
|
2019-05-30 16:55:08 +02:00
|
|
|
namespace tests\Unit\Domain\Right;
|
2019-01-12 15:40:54 +01:00
|
|
|
|
|
|
|
use PHPUnit\Framework\TestCase;
|
2019-05-30 16:55:08 +02:00
|
|
|
use Infinito\Domain\Right\RightLayerCombinationServiceInterface;
|
|
|
|
use Infinito\Domain\Right\RightLayerCombinationService;
|
2019-02-17 14:33:19 +01:00
|
|
|
use Infinito\DBAL\Types\Meta\Right\CRUDType;
|
|
|
|
use Infinito\DBAL\Types\Meta\Right\LayerType;
|
2019-01-12 15:40:54 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @author kevinfrantz
|
|
|
|
*/
|
|
|
|
class RightLayerCombinationServiceTest extends TestCase
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var RightLayerCombinationServiceInterface
|
|
|
|
*/
|
|
|
|
public $rightLayerCombinationService;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*
|
|
|
|
* @see \PHPUnit\Framework\TestCase::setUp()
|
|
|
|
*/
|
|
|
|
public function setUp()
|
|
|
|
{
|
|
|
|
$this->rightLayerCombinationService = new RightLayerCombinationService();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testBySource(): void
|
|
|
|
{
|
2019-02-25 13:32:37 +01:00
|
|
|
foreach (CRUDType::getValues() as $crudType) {
|
2019-01-12 15:40:54 +01:00
|
|
|
$layers = $this->rightLayerCombinationService->getPossibleLayers($crudType);
|
|
|
|
$this->assertContains(LayerType::SOURCE, $layers);
|
|
|
|
$sourceCruds = $this->rightLayerCombinationService->getPossibleCruds(LayerType::SOURCE);
|
|
|
|
$this->assertContains($crudType, $sourceCruds);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testByLaw(): void
|
|
|
|
{
|
|
|
|
foreach ([CRUDType::DELETE, CRUDType::CREATE] as $crudType) {
|
|
|
|
$layers = $this->rightLayerCombinationService->getPossibleLayers($crudType);
|
|
|
|
$this->assertNotContains(LayerType::LAW, $layers);
|
|
|
|
$sourceCruds = $this->rightLayerCombinationService->getPossibleCruds(LayerType::LAW);
|
|
|
|
$this->assertNotContains($crudType, $sourceCruds);
|
|
|
|
}
|
|
|
|
foreach ([CRUDType::READ, CRUDType::UPDATE] as $crudType) {
|
|
|
|
$layers = $this->rightLayerCombinationService->getPossibleLayers($crudType);
|
|
|
|
$this->assertContains(LayerType::LAW, $layers);
|
|
|
|
$sourceCruds = $this->rightLayerCombinationService->getPossibleCruds(LayerType::LAW);
|
|
|
|
$this->assertContains($crudType, $sourceCruds);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|