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

3
namespace Drupal\Tests\options\Functional;
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23

/**
* Tests the options allowed values api.
 *
 * @group options
*/
class OptionsDynamicValuesApiTest extends OptionsDynamicValuesTestBase {

  /**
   * 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);

24
    $expected_values = [
25 26 27 28
      $this->entity->label(),
      $this->entity->url(),
      $this->entity->uuid(),
      $this->entity->bundle(),
29
    ];
30 31 32 33 34
    $expected_values = array_combine($expected_values, $expected_values);
    $this->assertEqual($expected_values, $values);
  }

}