public function FieldTest::testAccess in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/views/tests/src/Unit/Plugin/field/FieldTest.php \Drupal\Tests\views\Unit\Plugin\field\FieldTest::testAccess()
@covers ::access
File
- core/
modules/ views/ tests/ src/ Unit/ Plugin/ field/ FieldTest.php, line 248 - Contains \Drupal\Tests\views\Unit\Plugin\field\FieldTest.
Class
- FieldTest
- @coversDefaultClass \Drupal\views\Plugin\views\field\Field @group views
Namespace
Drupal\Tests\views\Unit\Plugin\fieldCode
public function testAccess() {
$definition = [
'entity_type' => 'test_entity',
'field_name' => 'title',
];
$handler = new Field([], 'field', $definition, $this->entityManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer);
$handler->view = $this->executable;
$handler
->setViewsData($this->viewsData);
$this->view
->expects($this
->atLeastOnce())
->method('get')
->with('base_table')
->willReturn('test_entity_table');
$this->viewsData
->expects($this
->atLeastOnce())
->method('get')
->with('test_entity_table')
->willReturn([
'table' => [
'entity type' => 'test_entity',
],
]);
$access_control_handler = $this
->getMock('Drupal\\Core\\Entity\\EntityAccessControlHandlerInterface');
$this->entityManager
->expects($this
->atLeastOnce())
->method('getAccessControlHandler')
->with('test_entity')
->willReturn($access_control_handler);
$title_storage = $this
->getBaseFieldStorage();
$this->entityManager
->expects($this
->atLeastOnce())
->method('getFieldStorageDefinitions')
->with('test_entity')
->willReturn([
'title' => $title_storage,
]);
$account = $this
->getMock('Drupal\\Core\\Session\\AccountInterface');
$access_control_handler
->expects($this
->atLeastOnce())
->method('fieldAccess')
->with('view', $this
->anything(), $account, NULL, $this
->anything())
->willReturn(TRUE);
$this
->assertTrue($handler
->access($account));
}