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