class AreaTextTokenTest
Same name and namespace in other branches
- 11.x core/modules/views/tests/src/Kernel/Handler/AreaTextTokenTest.php \Drupal\Tests\views\Kernel\Handler\AreaTextTokenTest
Tests the token in text area handler.
@group views
Hierarchy
- class \Drupal\Tests\views\Kernel\Handler\AreaTextTokenTest
Expanded class hierarchy of AreaTextTokenTest
See also
\Drupal\views\Plugin\views\area\Text
File
-
core/
modules/ views/ tests/ src/ Kernel/ Handler/ AreaTextTokenTest.php, line 16
Namespace
Drupal\Tests\views\Kernel\HandlerView source
class AreaTextTokenTest extends ViewsKernelTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'system',
'user',
'filter',
];
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = [
'test_view',
];
/**
* {@inheritdoc}
*/
protected function setUp($import_test_views = TRUE) : void {
parent::setUp();
$this->installConfig([
'system',
'filter',
]);
$this->installEntitySchema('user');
}
/**
* Tests the token into text area plugin within header.
*/
public function testAreaTextToken() : void {
/** @var \Drupal\Core\Render\RendererInterface $renderer */
$renderer = $this->container
->get('renderer');
$view = Views::getView('test_view');
$view->setDisplay();
// Enable checkbox 'token replacement', add token into href in text header.
$string = '<a href="[site:url]">Added Site URL token in href</a>';
$view->displayHandlers
->get('default')
->overrideOption('header', [
'area' => [
'id' => 'area',
'table' => 'views',
'field' => 'area',
'content' => [
'value' => $string,
],
'tokenize' => TRUE,
],
]);
// Execute the view.
$this->executeView($view);
$build = $view->display_handler->handlers['header']['area']
->render();
$replaced_token = \Drupal::token()->replace('[site:url]');
$desired_output = str_replace('[site:url]', $replaced_token, $string);
$this->assertEquals(check_markup($desired_output), $renderer->renderRoot($build), 'Global token assessed in href');
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
AreaTextTokenTest::$modules | protected static | property | Modules to install. |
AreaTextTokenTest::$testViews | public static | property | Views used by this test. |
AreaTextTokenTest::setUp | protected | function | |
AreaTextTokenTest::testAreaTextToken | public | function | Tests the token into text area plugin within header. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.