function TelephoneFieldTest::testTelephoneWidget

Same name in other branches
  1. 9 core/modules/telephone/tests/src/Functional/TelephoneFieldTest.php \Drupal\Tests\telephone\Functional\TelephoneFieldTest::testTelephoneWidget()
  2. 8.9.x core/modules/telephone/tests/src/Functional/TelephoneFieldTest.php \Drupal\Tests\telephone\Functional\TelephoneFieldTest::testTelephoneWidget()
  3. 10 core/modules/telephone/tests/src/Functional/TelephoneFieldTest.php \Drupal\Tests\telephone\Functional\TelephoneFieldTest::testTelephoneWidget()

Tests to confirm the widget is setup.

@covers \Drupal\telephone\Plugin\Field\FieldWidget\TelephoneDefaultWidget::formElement

File

core/modules/telephone/tests/src/Functional/TelephoneFieldTest.php, line 90

Class

TelephoneFieldTest
Tests the creation of telephone fields.

Namespace

Drupal\Tests\telephone\Functional

Code

public function testTelephoneWidget() : void {
    $this->drupalGet('node/add/article');
    $this->assertSession()
        ->fieldValueEquals("field_telephone[0][value]", '');
    $this->assertSession()
        ->elementAttributeContains('css', 'input[name="field_telephone[0][value]"]', 'maxlength', (string) TelephoneItem::MAX_LENGTH);
    $this->assertSession()
        ->responseContains('placeholder="123-456-7890"');
}

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