class OptionsDynamicValuesValidationTest
Same name and namespace in other branches
- 11.x core/modules/options/tests/src/Kernel/OptionsDynamicValuesValidationTest.php \Drupal\Tests\options\Kernel\OptionsDynamicValuesValidationTest
- 10 core/modules/options/tests/src/Kernel/OptionsDynamicValuesValidationTest.php \Drupal\Tests\options\Kernel\OptionsDynamicValuesValidationTest
- 8.9.x core/modules/options/tests/src/Functional/OptionsDynamicValuesValidationTest.php \Drupal\Tests\options\Functional\OptionsDynamicValuesValidationTest
Tests the Options field allowed values function.
@group options
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\FunctionalTests\AssertLegacyTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\Tests\field\Functional\FieldTestBase implements \Drupal\Tests\BrowserTestBase
- class \Drupal\Tests\options\Functional\OptionsDynamicValuesTestBase implements \Drupal\Tests\field\Functional\FieldTestBase
- class \Drupal\Tests\options\Functional\OptionsDynamicValuesValidationTest implements \Drupal\Tests\options\Functional\OptionsDynamicValuesTestBase
- class \Drupal\Tests\options\Functional\OptionsDynamicValuesTestBase implements \Drupal\Tests\field\Functional\FieldTestBase
- class \Drupal\Tests\field\Functional\FieldTestBase implements \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of OptionsDynamicValuesValidationTest
File
-
core/
modules/ options/ tests/ src/ Functional/ OptionsDynamicValuesValidationTest.php, line 10
Namespace
Drupal\Tests\options\FunctionalView source
class OptionsDynamicValuesValidationTest extends OptionsDynamicValuesTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* Tests 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");
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.