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.
This commit is contained in:
Julien Fastré 2024-07-26 00:34:11 +02:00
parent 5fed42a623
commit 564813ef3d
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB

View File

@ -143,10 +143,26 @@ class AbstractStoredObjectVoterTest extends TestCase
$voter = $this->buildStoredObjectVoter(true, $this->repository, $this->security, $this->workflowDocumentService); $voter = $this->buildStoredObjectVoter(true, $this->repository, $this->security, $this->workflowDocumentService);
// Test voteOnAttribute method // Test voteOnAttribute method
$attribute = StoredObjectRoleEnum::SEE; $attribute = StoredObjectRoleEnum::EDIT;
$result = $voter->voteOnAttribute($attribute, $subject, $token); $result = $voter->voteOnAttribute($attribute, $subject, $token);
// Assert that access is denied when workflow is not allowed // Assert that access is denied when workflow is not allowed
$this->assertFalse($result); $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);
}
} }