/** * @covers ::checkAccess * * @dataProvider providerTestAccessDelete */ public function testAccessDelete($is_new, $expected) { $this->entityType->getAdminPermission()->willReturn('test permission'); $page = $this->prophesize(PageInterface::class); $page->isNew()->willReturn($is_new); $page->language()->willReturn($this->prophesize(LanguageInterface::class)->reveal()); $page->uuid()->shouldBeCalled(); $page->getEntityTypeId()->shouldBeCalled(); // Ensure that the cache tag is added for the temporary conditions. if ($is_new) { $page->getCacheTags()->willReturn(['page:1']); $page->getCacheContexts()->willReturn([]); $page->getCacheMaxAge()->willReturn(0); } else { $this->cacheContextsManager->assertValidTokens(['user.permissions'])->willReturn(TRUE); } $account = $this->prophesize(AccountInterface::class); $account->hasPermission('test permission')->willReturn(TRUE); $account->id()->shouldBeCalled(); $this->assertSame($expected, $this->pageAccess->access($page->reveal(), 'delete', $account->reveal())); }