public function WorkflowsFieldContraintTest::testValidTransitionsNoViolations in Workflows Field 8
Same name and namespace in other branches
- 2.x tests/src/Kernel/WorkflowsFieldContraintTest.php \Drupal\Tests\workflows_field\Kernel\WorkflowsFieldContraintTest::testValidTransitionsNoViolations()
@covers \Drupal\workflows_field\Plugin\Validation\Constraint\WorkflowsFieldContraint @covers \Drupal\workflows_field\Plugin\Validation\Constraint\WorkflowsFieldContraintValidator
File
- tests/
src/ Kernel/ WorkflowsFieldContraintTest.php, line 18
Class
- WorkflowsFieldContraintTest
- Tests the field constraints.
Namespace
Drupal\Tests\workflows_field\KernelCode
public function testValidTransitionsNoViolations() {
$this->container
->set('current_user', $this
->createUser([
'use bureaucracy_workflow transition approved_project',
'use bureaucracy_workflow transition ready_for_planning',
]));
$node = Node::create([
'title' => 'Foo',
'type' => 'project',
'field_status' => 'in_discussion',
]);
$node
->save();
// Same state does not cause a violation.
$node->field_status->value = 'in_discussion';
$violations = $node
->validate();
$this
->assertCount(0, $violations);
// A valid state does not cause a violation.
$node->field_status->value = 'approved';
$violations = $node
->validate();
$this
->assertCount(0, $violations);
}