You are here

protected function LinkFieldUITest::providerTestFieldUI in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/link/tests/src/Functional/LinkFieldUITest.php \Drupal\Tests\link\Functional\LinkFieldUITest::providerTestFieldUI()
  2. 10 core/modules/link/tests/src/Functional/LinkFieldUITest.php \Drupal\Tests\link\Functional\LinkFieldUITest::providerTestFieldUI()

Provides test data for ::testFieldUI().

1 call to LinkFieldUITest::providerTestFieldUI()
LinkFieldUITest::testFieldUI in core/modules/link/tests/src/Functional/LinkFieldUITest.php
Tests the link field UI.

File

core/modules/link/tests/src/Functional/LinkFieldUITest.php, line 95

Class

LinkFieldUITest
Tests link field UI functionality.

Namespace

Drupal\Tests\link\Functional

Code

protected function providerTestFieldUI() {

  // There are many combinations of field settings: where the description
  // should show: variation on internal, external, both; cardinality (where
  // the fieldset is hidden or used); and link text shown (required or
  // optional) or disabled. There are two descriptions: field and URL help
  // text.
  $cardinalities = [
    1,
    2,
  ];
  $title_settings = [
    DRUPAL_DISABLED,
    DRUPAL_OPTIONAL,
  ];
  $link_types = [
    LinkItemInterface::LINK_EXTERNAL,
    LinkItemInterface::LINK_GENERIC,
    LinkItemInterface::LINK_INTERNAL,
  ];

  // Test all variations of link types on all cardinalities.
  foreach ($cardinalities as $cardinality) {
    foreach ($link_types as $link_type) {

      // Now, test this with both the title enabled and disabled.
      foreach ($title_settings as $title_setting) {

        // Test both empty and non-empty labels.
        foreach ([
          TRUE,
          FALSE,
        ] as $label_provided) {

          // Generate a unique machine name for the field so it can be
          // identified in the test.
          $id = implode('_', [
            'link',
            $cardinality,
            $link_type,
            $title_setting,
            (int) $label_provided,
          ]);

          // Use a unique label that contains some HTML.
          $label = '<img src="http://example.com">' . $id;
          (yield [
            $cardinality,
            $link_type,
            $title_setting,
            $label_provided ? $label : '',
            $id,
          ]);
        }
      }
    }
  }
}