You are here

public function ElementTest::testPlaceHolderText in Drupal 9

Same name and namespace in other branches
  1. 8 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 30

Class

ElementTest
Tests building and processing of core form elements.

Namespace

Drupal\Tests\system\Functional\Form

Code

public function testPlaceHolderText() {
  $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'));
  }
}