diff --git a/core/modules/system/lib/Drupal/system/Tests/Validation/AllowedValuesConstraintValidatorTest.php b/core/modules/system/lib/Drupal/system/Tests/Validation/AllowedValuesConstraintValidatorTest.php index c409bea..e63ba6c 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Validation/AllowedValuesConstraintValidatorTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Validation/AllowedValuesConstraintValidatorTest.php @@ -7,6 +7,7 @@ namespace Drupal\system\Tests\Validation; +use Drupal\Core\TypedData\DataDefinition; use Drupal\simpletest\DrupalUnitTestBase; /** @@ -23,7 +24,7 @@ class AllowedValuesConstraintValidatorTest extends DrupalUnitTestBase { public static function getInfo() { return array( - 'name' => 'Tests AllowedValues validation constraint', + 'name' => 'Allowed values constraint', 'description' => 'Tests AllowedValues validation constraint with both valid and invalid values.', 'group' => 'Validation', ); @@ -31,23 +32,18 @@ public static function getInfo() { public function setUp() { parent::setUp(); - $this->typedData = $this->container->get('typed_data'); } /** - * Tests the AllowedValues validation constraint validator by creating a - * typedData integer definition with some AllowedValues, and then by tring to - * create a typedData object with both an allowed and a dissalowed value. + * Tests the AllowedValues validation constraint validator. + * + * For testing we define an integer with a set of allowed values. */ public function testValidation() { // Create a definition that specifies some AllowedValues. - $definition = array( - 'type' => 'integer', - 'constraints' => array( - 'AllowedValues' => array(1, 2, 3), - ), - ); + $definition = DataDefinition::create('integer') + ->addConstraint('AllowedValues', array(1, 2, 3)); // Test the validation. $typed_data = $this->typedData->create($definition, 1);