function ElementTest::testPlaceHolderText

Same name and namespace 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. 10 core/modules/system/tests/src/Functional/Form/ElementTest.php \Drupal\Tests\system\Functional\Form\ElementTest::testPlaceHolderText()

Tests placeholder text for elements that support placeholders.

File

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

Class

ElementTest
Tests building and processing of core form elements.

Namespace

Drupal\Tests\system\Functional\Form

Code

public 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.