Updated all the contrib modules to their latest versions.
[yaffs-website] / web / modules / contrib / token / tests / src / Kernel / ViewsTest.php
1 <?php
2
3 namespace Drupal\Tests\token\Kernel;
4
5 use Drupal\views\Tests\ViewTestData;
6 use Drupal\views\Views;
7
8 /**
9  * Test the views tokens.
10  *
11  * @group token
12  */
13 class ViewsTest extends KernelTestBase {
14
15   /**
16    * Modules to enable.
17    *
18    * @var array
19    */
20   public static $modules = ['views', 'block'];
21
22   /**
23    * Views used by this test.
24    *
25    * @var array
26    */
27   public static $testViews = ['token_views_test'];
28
29   /**
30    * {@inheritdoc}
31    */
32   protected function setUp() {
33     parent::setUp();
34     $this->installEntitySchema('user');
35     ViewTestData::createTestViews(get_class($this), ['token_module_test']);
36   }
37
38   /**
39    * Tests path token replacements generated from a view without a path.
40    */
41   public function testTokenReplacementNoPath() {
42     $token_handler = \Drupal::token();
43     $view = Views::getView('token_views_test');
44     $view->setDisplay('block_1');
45     $view->execute();
46
47     $this->assertSame('', $token_handler->replace('[view:url]', ['view' => $view]), 'Token [view:url] is empty for views without path.');
48   }
49
50 }