public function UserAccessControlHandlerTest::assertFieldAccess in Zircon Profile 8
Same name and namespace in other branches
- 8.0 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 125 - Contains \Drupal\Tests\user\Unit\UserAccessControlHandlerTest.
Class
- UserAccessControlHandlerTest
- Tests the user access controller.
Namespace
Drupal\Tests\user\UnitCode
public function assertFieldAccess($field, $viewer, $target, $view, $edit) {
$field_definition = $this
->getMock('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 (array(
'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);
}
}