dataAccessControl = $this->createMock(DataAccessControl::class); $this->user = $this->createMock(User::class); $this->subject = new PermissionChecker(); $this->subject->withAccessControl($this->dataAccessControl); } public function testHasWriteAccess(): void { $this->mockHasPrivileges(PermissionChecker::PERMISSION_WRITE); $this->assertTrue($this->subject->hasWriteAccess('uri', $this->user)); } public function testHasReadAccess(): void { $this->mockHasPrivileges(PermissionChecker::PERMISSION_READ); $this->assertTrue($this->subject->hasReadAccess('uri', $this->user)); } public function testHasGrantAccess(): void { $this->mockHasPrivileges(PermissionChecker::PERMISSION_GRANT); $this->assertTrue($this->subject->hasGrantAccess('uri', $this->user)); } private function mockHasPrivileges(string $permission): void { $this->dataAccessControl ->method('hasPrivileges') ->with( $this->user, [ 'uri' => $permission ] ) ->willReturn(true); } }