3 namespace Drupal\Tests\views\Functional\Handler;
5 use Drupal\Tests\views\Functional\ViewTestBase;
8 * Tests the placeholder text on the appropriate filter handlers.
12 class FilterPlaceholderTextTest extends ViewTestBase {
15 * Views used by this test.
19 public static $testViews = ['test_filter_placeholder_text'];
24 public static $modules = ['node'];
27 * Tests that HTML placeholders are added, when appropriate.
29 public function testPlaceholderText() {
30 $this->drupalGet('placeholder-text-test');
32 // String filter that has no placeholder configured.
33 $results = $this->cssSelect('input[name=title]');
34 $this->assertFalse($results[0]->hasAttribute('placeholder'));
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'));
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'));
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'));