You are here

class OptionsDynamicValuesApiTest in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/options/tests/src/Functional/OptionsDynamicValuesApiTest.php \Drupal\Tests\options\Functional\OptionsDynamicValuesApiTest
  2. 9 core/modules/options/tests/src/Functional/OptionsDynamicValuesApiTest.php \Drupal\Tests\options\Functional\OptionsDynamicValuesApiTest

Tests the options allowed values api.

@group options

Hierarchy

  • class \Drupal\Tests\options\Functional\OptionsDynamicValuesApiTest extends \Drupal\Tests\options\Functional\OptionsDynamicValuesTestBase

Expanded class hierarchy of OptionsDynamicValuesApiTest

File

core/modules/options/tests/src/Functional/OptionsDynamicValuesApiTest.php, line 10

Namespace

Drupal\Tests\options\Functional
View source
class OptionsDynamicValuesApiTest extends OptionsDynamicValuesTestBase {

  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'stark';

  /**
   * Tests options_allowed_values().
   *
   * @see options_test_dynamic_values_callback()
   */
  public function testOptionsAllowedValues() {

    // Test allowed values without passed $items.
    $values = options_allowed_values($this->fieldStorage);
    $this
      ->assertEquals([], $values);
    $values = options_allowed_values($this->fieldStorage, $this->entity);
    $expected_values = [
      $this->entity
        ->label(),
      $this->entity
        ->toUrl()
        ->toString(),
      $this->entity
        ->uuid(),
      $this->entity
        ->bundle(),
    ];
    $expected_values = array_combine($expected_values, $expected_values);
    $this
      ->assertEquals($expected_values, $values);
  }

}

Members