OptionsDynamicValuesApiTest.php 932 Bytes
Newer Older
1 2
<?php

3
namespace Drupal\Tests\options\Functional;
4 5

/**
6
 * Tests the options allowed values api.
7 8
 *
 * @group options
9
 */
10 11
class OptionsDynamicValuesApiTest extends OptionsDynamicValuesTestBase {

12 13 14 15 16
  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'stark';

17 18 19 20 21 22 23 24 25 26 27 28
  /**
   * 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->assertEqual([], $values);

    $values = options_allowed_values($this->fieldStorage, $this->entity);

29
    $expected_values = [
30
      $this->entity->label(),
31
      $this->entity->toUrl()->toString(),
32 33
      $this->entity->uuid(),
      $this->entity->bundle(),
34
    ];
35 36 37 38 39
    $expected_values = array_combine($expected_values, $expected_values);
    $this->assertEqual($expected_values, $values);
  }

}