Implemented testRightAppliesToAll for SecureRequestedRightCheckerService

This commit is contained in:
Kevin Frantz 2019-02-16 16:45:05 +01:00
parent 956a717610
commit a85e20fdc0

View File

@ -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));
}
}