public function UniqueFieldValidationRuleTest::testSomething in Field Validation 8
Tests uniqueness of the value depending on scope.
File
- tests/
src/ Kernel/ Plugin/ FieldValidationRule/ UniqueFieldValidationRuleTest.php, line 132
Class
- UniqueFieldValidationRuleTest
- Tests UniqueFieldValidationRule.
Namespace
Drupal\Tests\field_validation\Kernel\Plugin\FieldValidationRuleCode
public function testSomething() {
$this
->assertConstraintFail($this->entity, self::FIELD_NAME, '1337', $this->ruleSet);
$this
->assertConstraintPass($this->entity, self::FIELD_NAME, '9001');
$this
->assertConstraintPass($this->entityOtherBundle, self::FIELD_NAME, '9001');
$this
->assertConstraintPass($this->entityOtherBundle, self::FIELD_NAME, '1337');
$this
->updateSettings([
'scope' => 'entity',
], self::RULE_ID, self::RULE_TITLE, $this->ruleSet, self::FIELD_NAME);
$this
->assertConstraintPass($this->entity, self::FIELD_NAME, '9001');
$this
->assertConstraintFail($this->entity, self::FIELD_NAME, '1337', $this->ruleSet);
}