mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2024-12-04 23:17:19 +01:00
Implemented testRightAppliesToAll for SecureRequestedRightCheckerService
This commit is contained in:
parent
956a717610
commit
a85e20fdc0
@ -11,6 +11,7 @@ use App\Domain\RequestManagement\Right\RequestedRight;
|
||||
use App\Domain\RequestManagement\Entity\RequestedEntityInterface;
|
||||
use App\Domain\SecureManagement\SecureRequestedRightCheckerService;
|
||||
use App\Domain\RightManagement\RightTransformerService;
|
||||
use App\Domain\RequestManagement\Right\RequestedRightInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
@ -72,4 +73,31 @@ class SecureRequestedRightCheckerServiceTest extends TestCase
|
||||
$result = $secureEntityChecker->check($requestedRight);
|
||||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
public function testRightAppliesToAll(): void
|
||||
{
|
||||
$reciever = new class() extends AbstractSource {
|
||||
};
|
||||
$layer = LayerType::SOURCE;
|
||||
$crud = CRUDType::READ;
|
||||
$source = new class() extends AbstractSource {
|
||||
};
|
||||
$requestedRight = $this->createMock(RequestedRightInterface::class);
|
||||
$requestedRight->method('getCrud')->willReturn($crud);
|
||||
$requestedRight->method('getLayer')->willReturn($layer);
|
||||
$requestedRight->method('getReciever')->willReturn($reciever);
|
||||
$requestedRight->method('getSource')->willReturn($source);
|
||||
$rightTransformerService = new RightTransformerService();
|
||||
$secureEntityChecker = new SecureRequestedRightCheckerService($rightTransformerService);
|
||||
$this->assertFalse($secureEntityChecker->check($requestedRight));
|
||||
$right = new Right();
|
||||
$right->setCrud($crud);
|
||||
$right->setLayer($layer);
|
||||
$right->setSource($source);
|
||||
$source->getLaw()->getRights()->add($right);
|
||||
$this->assertTrue($secureEntityChecker->check($requestedRight));
|
||||
$right->setReciever(new class() extends AbstractSource {
|
||||
});
|
||||
$this->assertFalse($secureEntityChecker->check($requestedRight));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user