infinito/application/symfony/tests/Unit/Domain/Right/RightTransformerServiceTest.php

42 lines
1.6 KiB
PHP
Raw Normal View History

2019-01-27 02:08:11 +01:00
<?php
namespace tests\Unit\Domain\Right;
2019-01-27 02:08:11 +01:00
use Infinito\DBAL\Types\Meta\Right\CRUDType;
use Infinito\DBAL\Types\Meta\Right\LayerType;
use Infinito\Domain\Request\Entity\RequestedEntityInterface;
2020-04-02 21:13:35 +02:00
use Infinito\Domain\Request\Right\RequestedRight;
use Infinito\Domain\Right\RightTransformerService;
use Infinito\Entity\Source\SourceInterface;
use PHPUnit\Framework\TestCase;
2019-01-27 02:08:11 +01:00
/**
* @author kevinfrantz
*/
class RightTransformerServiceTest extends TestCase
{
public function testTransformation(): void
{
$source = $this->createMock(SourceInterface::class);
$crud = CRUDType::READ;
$layer = LayerType::SOURCE;
$reciever = $this->createMock(SourceInterface::class);
$requestedEntity = $this->createMock(RequestedEntityInterface::class);
$requestedEntity->method('hasId')->willReturn(123);
$requestedEntity->method('getEntity')->willReturn($source);
2019-04-15 01:37:17 +02:00
$requestedEntity->method('hasIdentity')->willReturn(true);
2019-01-27 02:08:11 +01:00
$requestedEntity->method('hasRequestedRight')->willReturn(true);
$requestedRight = new RequestedRight();
$requestedRight->setActionType($crud);
2019-01-27 02:08:11 +01:00
$requestedRight->setLayer($layer);
$requestedRight->setRequestedEntity($requestedEntity);
$requestedRight->setReciever($reciever);
$transformer = new RightTransformerService();
$right = $transformer->transform($requestedRight);
$this->assertEquals($crud, $right->getActionType());
2019-01-27 02:08:11 +01:00
$this->assertEquals($layer, $right->getLayer());
$this->assertEquals($reciever, $right->getReciever());
$this->assertEquals($source, $right->getSource());
}
}