You are here

protected function ViewTestBase::helperButtonHasLabel in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/views/tests/src/Functional/ViewTestBase.php \Drupal\Tests\views\Functional\ViewTestBase::helperButtonHasLabel()
  2. 10 core/modules/views/tests/src/Functional/ViewTestBase.php \Drupal\Tests\views\Functional\ViewTestBase::helperButtonHasLabel()

Asserts the existence of a button with a certain ID and label.

Parameters

string $id: The HTML ID of the button

string $expected_label: The expected label for the button.

string $message: (optional) A custom message to display with the assertion. If no custom message is provided, the message will indicate the button label.

Throws

\Behat\Mink\Exception\ElementNotFoundException

5 calls to ViewTestBase::helperButtonHasLabel()
ExposedFormTest::testInputRequired in core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php
Tests the input required exposed form type.
ExposedFormTest::testResetButton in core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php
Tests whether the reset button works on an exposed form.
ExposedFormTest::testSubmitButton in core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php
Tests the submit button.
ExposedFormUITest::testExposedAdminUi in core/modules/views_ui/tests/src/Functional/ExposedFormUITest.php
Tests the admin interface of exposed filter and sort items.
ExposedFormUITest::testGroupedFilterAdminUi in core/modules/views_ui/tests/src/Functional/ExposedFormUITest.php
Tests the admin interface of exposed grouped filters.

File

core/modules/views/tests/src/Functional/ViewTestBase.php, line 104

Class

ViewTestBase
Defines a base class for Views testing in the full web test environment.

Namespace

Drupal\Tests\views\Functional

Code

protected function helperButtonHasLabel($id, $expected_label, $message = 'Label has the expected value: %label.') {
  $xpath = $this
    ->assertSession()
    ->buildXPathQuery('//button[@id=:value]|//input[@id=:value]', [
    ':value' => $id,
  ]);
  $field = $this
    ->getSession()
    ->getPage()
    ->find('xpath', $xpath);
  if (empty($field)) {
    throw new ElementNotFoundException($this
      ->getSession()
      ->getDriver(), 'form field', 'id', $field);
  }
  $this
    ->assertEquals($expected_label, $field
    ->getValue());
}