ViewsTest.php in Token 8
File
tests/src/Kernel/ViewsTest.php
View source
<?php
namespace Drupal\Tests\token\Kernel;
use Drupal\views\Tests\ViewTestData;
use Drupal\views\Views;
class ViewsTest extends KernelTestBase {
public static $modules = [
'views',
'block',
];
public static $testViews = [
'token_views_test',
];
protected function setUp() {
parent::setUp();
$this
->installEntitySchema('user');
ViewTestData::createTestViews(get_class($this), [
'token_module_test',
]);
}
public function testTokenReplacementNoPath() {
$token_handler = \Drupal::token();
$view = Views::getView('token_views_test');
$view
->setDisplay('block_1');
$view
->execute();
$this
->assertSame('', $token_handler
->replace('[view:url]', [
'view' => $view,
]), 'Token [view:url] is empty for views without path.');
}
}