3 namespace Drupal\Tests\options\Functional;
6 * Tests the Options field allowed values function.
10 class OptionsDynamicValuesValidationTest extends OptionsDynamicValuesTestBase {
13 * Test that allowed values function gets the entity.
15 public function testDynamicAllowedValues() {
16 // Verify that validation passes against every value we had.
17 foreach ($this->test as $key => $value) {
18 $this->entity->test_options->value = $value;
19 $violations = $this->entity->test_options->validate();
20 $this->assertEqual(count($violations), 0, "$key is a valid value");
23 // Now verify that validation does not pass against anything else.
24 foreach ($this->test as $key => $value) {
25 $this->entity->test_options->value = is_numeric($value) ? (100 - $value) : ('X' . $value);
26 $violations = $this->entity->test_options->validate();
27 $this->assertEqual(count($violations), 1, "$key is not a valid value");