user = $this->createMock(User::class); $this->table = $this->createMock(Table::class); $this->accessCheckerFactory = $this->createMock(AccessCheckerFactory::class); $this->ownershipCheckerFactory = $this->createMock(OwnershipCheckerFactory::class); $this->tableFactory = $this->createMock(TableFactory::class); $this->mapFactory = $this->createMock(MapFactory::class); $this->globalRestriction = $this->createMock(GlobalRestriction::class); $this->aclManager = new AclManager( $this->accessCheckerFactory, $this->ownershipCheckerFactory, $this->tableFactory, $this->mapFactory, $this->globalRestriction, $this->createMock(OwnerUserFieldProvider::class), $this->createMock(EntityManager::class) ); } private function initTableFactory(User $user, Table $table): void { $this->tableFactory ->expects($this->once()) ->method('create') ->with($user) ->willReturn($table); } public function testGetPermissionLevel1(): void { $this->initTableFactory($this->user, $this->table); $this->table ->expects($this->once()) ->method('getPermissionLevel') ->with('assignment') ->willReturn(Table::LEVEL_YES); $this->aclManager->getPermissionLevel($this->user, 'assignment'); } public function testGetPermissionLevel2(): void { $this->initTableFactory($this->user, $this->table); $this->table ->expects($this->once()) ->method('getPermissionLevel') ->with('assignment') ->willReturn(Table::LEVEL_YES); $this->aclManager->getPermissionLevel($this->user, 'assignmentPermission'); } }