
| Current Path : /var/www/html1/web/core/modules/options/tests/src/Functional/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/www/html1/web/core/modules/options/tests/src/Functional/OptionsDynamicValuesValidationTest.php |
<?php
namespace Drupal\Tests\options\Functional;
/**
* Tests the Options field allowed values function.
*
* @group options
*/
class OptionsDynamicValuesValidationTest extends OptionsDynamicValuesTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* Test that allowed values function gets the entity.
*/
public function testDynamicAllowedValues() {
// Verify that validation passes against every value we had.
foreach ($this->test as $key => $value) {
$this->entity->test_options->value = $value;
$violations = $this->entity->test_options->validate();
$this->assertCount(0, $violations, "$key is a valid value");
}
// Now verify that validation does not pass against anything else.
foreach ($this->test as $key => $value) {
$this->entity->test_options->value = is_numeric($value) ? (100 - $value) : ('X' . $value);
$violations = $this->entity->test_options->validate();
$this->assertCount(1, $violations, "$key is not a valid value");
}
}
}