function UserAccessControlHandlerTest::assertFieldAccess
Same name in other branches
- 9 core/modules/user/tests/src/Unit/UserAccessControlHandlerTest.php \Drupal\Tests\user\Unit\UserAccessControlHandlerTest::assertFieldAccess()
- 10 core/modules/user/tests/src/Unit/UserAccessControlHandlerTest.php \Drupal\Tests\user\Unit\UserAccessControlHandlerTest::assertFieldAccess()
- 11.x core/modules/user/tests/src/Unit/UserAccessControlHandlerTest.php \Drupal\Tests\user\Unit\UserAccessControlHandlerTest::assertFieldAccess()
Asserts correct field access grants for a field.
6 calls to UserAccessControlHandlerTest::assertFieldAccess()
- UserAccessControlHandlerTest::testAdminFieldAccess in core/
modules/ user/ tests/ src/ Unit/ UserAccessControlHandlerTest.php - Tests that private user settings cannot be viewed by other users.
- UserAccessControlHandlerTest::testCreatedAccess in core/
modules/ user/ tests/ src/ Unit/ UserAccessControlHandlerTest.php - Tests the user created field access.
- UserAccessControlHandlerTest::testHiddenUserSettings in core/
modules/ user/ tests/ src/ Unit/ UserAccessControlHandlerTest.php - Tests that private user settings cannot be viewed by other users.
- UserAccessControlHandlerTest::testNonExistingFieldAccess in core/
modules/ user/ tests/ src/ Unit/ UserAccessControlHandlerTest.php - Tests access to a non-existing base field.
- UserAccessControlHandlerTest::testPasswordAccess in core/
modules/ user/ tests/ src/ Unit/ UserAccessControlHandlerTest.php - Tests that passwords cannot be viewed, just edited.
File
-
core/
modules/ user/ tests/ src/ Unit/ UserAccessControlHandlerTest.php, line 120
Class
- UserAccessControlHandlerTest
- Tests the user access controller.
Namespace
Drupal\Tests\user\UnitCode
public function assertFieldAccess($field, $viewer, $target, $view, $edit) {
$field_definition = $this->createMock('Drupal\\Core\\Field\\FieldDefinitionInterface');
$field_definition->expects($this->any())
->method('getName')
->will($this->returnValue($field));
$this->items
->expects($this->any())
->method('getEntity')
->will($this->returnValue($this->{$target}));
foreach ([
'view' => $view,
'edit' => $edit,
] as $operation => $result) {
$result_text = !isset($result) ? 'null' : ($result ? 'true' : 'false');
$message = "User '{$field}' field access returns '{$result_text}' with operation '{$operation}' for '{$viewer}' accessing '{$target}'";
$this->assertSame($result, $this->accessControlHandler
->fieldAccess($operation, $field_definition, $this->{$viewer}, $this->items), $message);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.