OptionsDynamicValuesValidationTest.php in Drupal 10
File
core/modules/options/tests/src/Functional/OptionsDynamicValuesValidationTest.php
View source
<?php
namespace Drupal\Tests\options\Functional;
class OptionsDynamicValuesValidationTest extends OptionsDynamicValuesTestBase {
protected $defaultTheme = 'stark';
public function testDynamicAllowedValues() {
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");
}
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");
}
}
}