Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / web / core / modules / views / tests / src / Functional / Handler / FilterPlaceholderTextTest.php
1 <?php
2
3 namespace Drupal\Tests\views\Functional\Handler;
4
5 use Drupal\Tests\views\Functional\ViewTestBase;
6
7 /**
8  * Tests the placeholder text on the appropriate filter handlers.
9  *
10  * @group views
11  */
12 class FilterPlaceholderTextTest extends ViewTestBase {
13
14   /**
15    * Views used by this test.
16    *
17    * @var array
18    */
19   public static $testViews = ['test_filter_placeholder_text'];
20
21   /**
22    * {@inheritdoc}
23    */
24   public static $modules = ['node'];
25
26   /**
27    * Tests that HTML placeholders are added, when appropriate.
28    */
29   public function testPlaceholderText() {
30     $this->drupalGet('placeholder-text-test');
31
32     // String filter that has no placeholder configured.
33     $results = $this->cssSelect('input[name=title]');
34     $this->assertFalse($results[0]->hasAttribute('placeholder'));
35
36     // String filter that has placeholder configured.
37     $results = $this->cssSelect('input[name=title_with_placeholder]');
38     $this->assertTrue($results[0]->hasAttribute('placeholder'));
39     $this->assertEquals('title placeholder', $results[0]->getAttribute('placeholder'));
40
41     // Numeric filter that has no placeholders configured.
42     $results = $this->cssSelect('input[name="created[value]"]');
43     $this->assertFalse($results[0]->hasAttribute('placeholder'));
44     $results = $this->cssSelect('input[name="created[min]"]');
45     $this->assertFalse($results[0]->hasAttribute('placeholder'));
46     $results = $this->cssSelect('input[name="created[max]"]');
47     $this->assertFalse($results[0]->hasAttribute('placeholder'));
48
49     // Numeric filter that has all placeholders configured.
50     $results = $this->cssSelect('input[name="created_with_placeholders[value]"]');
51     $this->assertTrue($results[0]->hasAttribute('placeholder'));
52     $this->assertEquals('created placeholder', $results[0]->getAttribute('placeholder'));
53     $results = $this->cssSelect('input[name="created_with_placeholders[min]"]');
54     $this->assertTrue($results[0]->hasAttribute('placeholder'));
55     $this->assertEquals('min placeholder', $results[0]->getAttribute('placeholder'));
56     $results = $this->cssSelect('input[name="created_with_placeholders[max]"]');
57     $this->assertTrue($results[0]->hasAttribute('placeholder'));
58     $this->assertEquals('max placeholder', $results[0]->getAttribute('placeholder'));
59   }
60
61 }