public function AreaTest::testAreaAccess in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/views/src/Tests/Handler/AreaTest.php \Drupal\views\Tests\Handler\AreaTest::testAreaAccess()
Tests the access for an area.
File
- core/
modules/ views/ src/ Tests/ Handler/ AreaTest.php, line 156 - Contains \Drupal\views\Tests\Handler\AreaTest.
Class
- AreaTest
- Tests the plugin base of the area handler.
Namespace
Drupal\views\Tests\HandlerCode
public function testAreaAccess() {
// Test with access denied for the area handler.
$view = Views::getView('test_example_area_access');
$view
->initDisplay();
$view
->initHandlers();
$handlers = $view->display_handler
->getHandlers('empty');
$this
->assertEqual(0, count($handlers));
$output = $view
->preview();
$output = \Drupal::service('renderer')
->renderRoot($output);
// The area output should not be present since access was denied.
$this
->assertFalse(strpos($output, 'a custom string') !== FALSE);
$view
->destroy();
// Test with access granted for the area handler.
$view = Views::getView('test_example_area_access');
$view
->initDisplay();
$view->display_handler
->overrideOption('empty', [
'test_example' => [
'field' => 'test_example',
'id' => 'test_example',
'table' => 'views',
'plugin_id' => 'test_example',
'string' => 'a custom string',
'custom_access' => TRUE,
],
]);
$view
->initHandlers();
$handlers = $view->display_handler
->getHandlers('empty');
$output = $view
->preview();
$output = \Drupal::service('renderer')
->renderRoot($output);
$this
->assertTrue(strpos($output, 'a custom string') !== FALSE);
$this
->assertEqual(1, count($handlers));
}