From 564813ef3dfb97a11f7876d69d67eedf9daf713f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 26 Jul 2024 00:34:11 +0200 Subject: [PATCH] Change attribute in test and add new test method Updated an existing test to use the 'EDIT' attribute instead of 'SEE' in AbstractStoredObjectVoterTest.php. Added a new test method to check the 'SEE' attribute when the workflow is allowed, ensuring proper access validation. --- .../AbstractStoredObjectVoterTest.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillDocStoreBundle/Tests/Security/Authorization/AbstractStoredObjectVoterTest.php b/src/Bundle/ChillDocStoreBundle/Tests/Security/Authorization/AbstractStoredObjectVoterTest.php index 4f420223a..3f6a5538d 100644 --- a/src/Bundle/ChillDocStoreBundle/Tests/Security/Authorization/AbstractStoredObjectVoterTest.php +++ b/src/Bundle/ChillDocStoreBundle/Tests/Security/Authorization/AbstractStoredObjectVoterTest.php @@ -143,10 +143,26 @@ class AbstractStoredObjectVoterTest extends TestCase $voter = $this->buildStoredObjectVoter(true, $this->repository, $this->security, $this->workflowDocumentService); // Test voteOnAttribute method - $attribute = StoredObjectRoleEnum::SEE; + $attribute = StoredObjectRoleEnum::EDIT; $result = $voter->voteOnAttribute($attribute, $subject, $token); // Assert that access is denied when workflow is not allowed $this->assertFalse($result); } + + public function testVoteOnAttributeAllowedWorkflowAllowedToSeeDocument(): void + { + list($user, $token, $subject, $entity) = $this->setupMockObjects(); + + // Setup mocks for voteOnAttribute method + $this->setupMocksForVoteOnAttribute($user, $token, true, $entity, false); + $voter = $this->buildStoredObjectVoter(true, $this->repository, $this->security, $this->workflowDocumentService); + + // Test voteOnAttribute method + $attribute = StoredObjectRoleEnum::SEE; + $result = $voter->voteOnAttribute($attribute, $subject, $token); + + // Assert that access is denied when workflow is not allowed + $this->assertTrue($result); + } }