function ElementTest::testPlaceHolderText

Same name in other branches
  1. 9 core/modules/system/tests/src/Functional/Form/ElementTest.php \Drupal\Tests\system\Functional\Form\ElementTest::testPlaceHolderText()
  2. 8.9.x core/modules/system/tests/src/Functional/Form/ElementTest.php \Drupal\Tests\system\Functional\Form\ElementTest::testPlaceHolderText()
  3. 11.x core/modules/system/tests/src/Functional/Form/ElementTest.php \Drupal\Tests\system\Functional\Form\ElementTest::testPlaceHolderText()

Tests placeholder text for elements that support placeholders.

1 call to ElementTest::testPlaceHolderText()
ElementTest::testFormElements in core/modules/system/tests/src/Functional/Form/ElementTest.php
Test form elements.

File

core/modules/system/tests/src/Functional/Form/ElementTest.php, line 45

Class

ElementTest
Tests building and processing of core form elements.

Namespace

Drupal\Tests\system\Functional\Form

Code

protected function testPlaceHolderText() : void {
    $this->drupalGet('form-test/placeholder-text');
    foreach ([
        'textfield',
        'tel',
        'url',
        'password',
        'email',
        'number',
        'textarea',
    ] as $type) {
        $field = $this->assertSession()
            ->fieldExists("edit-{$type}");
        $this->assertSame('placeholder-text', $field->getAttribute('placeholder'));
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.