diff core/modules/options/tests/src/Functional/OptionsDynamicValuesApiTest.php @ 0:c75dbcec494b

Initial commit from drush-created site
author Chris Cannam
date Thu, 05 Jul 2018 14:24:15 +0000
parents
children 12f9dff5fda9
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/modules/options/tests/src/Functional/OptionsDynamicValuesApiTest.php	Thu Jul 05 14:24:15 2018 +0000
@@ -0,0 +1,34 @@
+<?php
+
+namespace Drupal\Tests\options\Functional;
+
+/**
+* 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);
+
+    $expected_values = [
+      $this->entity->label(),
+      $this->entity->url(),
+      $this->entity->uuid(),
+      $this->entity->bundle(),
+    ];
+    $expected_values = array_combine($expected_values, $expected_values);
+    $this->assertEqual($expected_values, $values);
+  }
+
+}