comparison core/modules/options/tests/src/Functional/OptionsDynamicValuesValidationTest.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children 129ea1e6d783
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
1 <?php
2
3 namespace Drupal\Tests\options\Functional;
4
5 /**
6 * Tests the Options field allowed values function.
7 *
8 * @group options
9 */
10 class OptionsDynamicValuesValidationTest extends OptionsDynamicValuesTestBase {
11 /**
12 * Test that allowed values function gets the entity.
13 */
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");
20 }
21
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");
27 }
28 }
29
30 }