function MediaLibraryAccessTest::assertAccess
Same name in other branches
- 8.9.x core/modules/media_library/tests/src/Kernel/MediaLibraryAccessTest.php \Drupal\Tests\media_library\Kernel\MediaLibraryAccessTest::assertAccess()
- 10 core/modules/media_library/tests/src/Kernel/MediaLibraryAccessTest.php \Drupal\Tests\media_library\Kernel\MediaLibraryAccessTest::assertAccess()
- 11.x core/modules/media_library/tests/src/Kernel/MediaLibraryAccessTest.php \Drupal\Tests\media_library\Kernel\MediaLibraryAccessTest::assertAccess()
Asserts various aspects of an access result.
Parameters
\Drupal\Core\Access\AccessResult $access_result: The access result.
bool $is_allowed: The expected access status.
string $expected_reason: (optional) The expected reason attached to the access result.
string[] $expected_cache_tags: (optional) The expected cache tags attached to the access result.
string[] $expected_cache_contexts: (optional) The expected cache contexts attached to the access result.
5 calls to MediaLibraryAccessTest::assertAccess()
- MediaLibraryAccessTest::testEditorOpenerAccess in core/
modules/ media_library/ tests/ src/ Kernel/ MediaLibraryAccessTest.php - @covers \Drupal\media_library\MediaLibraryEditorOpener::checkAccess
- MediaLibraryAccessTest::testFieldWidgetEntityCreateAccess in core/
modules/ media_library/ tests/ src/ Kernel/ MediaLibraryAccessTest.php - Tests that the field widget opener respects entity creation permissions.
- MediaLibraryAccessTest::testFieldWidgetEntityEditAccess in core/
modules/ media_library/ tests/ src/ Kernel/ MediaLibraryAccessTest.php - Tests that the field widget opener respects entity-specific access.
- MediaLibraryAccessTest::testFieldWidgetEntityFieldAccess in core/
modules/ media_library/ tests/ src/ Kernel/ MediaLibraryAccessTest.php - Tests that the field widget opener respects entity field-level access.
- MediaLibraryAccessTest::testViewAccess in core/
modules/ media_library/ tests/ src/ Kernel/ MediaLibraryAccessTest.php - Tests that media library access respects the media_library view.
File
-
core/
modules/ media_library/ tests/ src/ Kernel/ MediaLibraryAccessTest.php, line 433
Class
- MediaLibraryAccessTest
- Tests the media library access.
Namespace
Drupal\Tests\media_library\KernelCode
private function assertAccess(AccessResult $access_result, bool $is_allowed, string $expected_reason = NULL, array $expected_cache_tags = [], array $expected_cache_contexts = []) : void {
$this->assertSame($is_allowed, $access_result->isAllowed());
if ($access_result instanceof AccessResultReasonInterface && isset($expected_reason)) {
$this->assertSame($expected_reason, $access_result->getReason());
}
$this->assertEqualsCanonicalizing($expected_cache_tags, $access_result->getCacheTags());
$this->assertEqualsCanonicalizing($expected_cache_contexts, $access_result->getCacheContexts());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.