permissionChecker = $this->createMock(PermissionCheckerInterface::class); $this->subject = new MediaBrowserPermissionsMapper(); $this->subject->setServiceLocator( $this->getServiceLocatorMock( [ PermissionChecker::class => $this->permissionChecker, ] ) ); } public function testMapWithoutAccessControlEnabledGrantReadAndWritePermissions(): void { $this->assertEquals( [ 'permissions' => [ PermissionCheckerInterface::PERMISSION_READ, PermissionCheckerInterface::PERMISSION_WRITE, ] ], $this->subject->map([], 'uri') ); } public function testMapWithAccessControlEnabledGrantReadAndWritePermissions(): void { $resourceUri = 'uri'; $this->subject->enableAccessControl(); $this->permissionChecker ->expects($this->exactly(1)) ->method('hasReadAccess') ->with($resourceUri) ->willReturn(false); $this->permissionChecker ->expects($this->exactly(1)) ->method('hasWriteAccess') ->with($resourceUri) ->willReturn(false); $this->assertEquals( [ 'permissions' => [] ], $this->subject->map([], $resourceUri) ); } }