You are here

protected function EmptyValuesTest::assertUniqueSubmitButtons in FileField Sources 8

Check that there is only one submit button of a source.

1 call to EmptyValuesTest::assertUniqueSubmitButtons()
EmptyValuesTest::testAllSourcesEnabled in tests/src/Functional/EmptyValuesTest.php
Tests all sources enabled.

File

tests/src/Functional/EmptyValuesTest.php, line 71

Class

EmptyValuesTest
Tests empty values.

Namespace

Drupal\Tests\filefield_sources\Functional

Code

protected function assertUniqueSubmitButtons() {
  $buttons = [
    $this->fieldName . '_0_attach' => t('Attach'),
    $this->fieldName . '_0_clipboard_upload_button' => t('Upload'),
    $this->fieldName . '_0_autocomplete_select' => t('Select'),
    $this->fieldName . '_0_transfer' => t('Transfer'),
    $this->fieldName . '_0_upload_button' => t('Upload'),
    $this->fieldName . '_0_imce_select' => t('Select'),
  ];
  foreach ($buttons as $button_name => $button_label) {

    // Ensure that there is only one button with name.
    $buttons = $this
      ->xpath('//input[@name="' . $button_name . '" and @value="' . $button_label . '"]');
    $this
      ->assertEquals(count($buttons), 1, new FormattableMarkup('There is only one button with name %name and label %label', [
      '%name' => $button_name,
      '%label' => $button_label,
    ]));
  }
}