You are here

public function WorkflowsFieldContraintTest::testNotAllowedTransition in Workflows Field 2.x

Same name and namespace in other branches
  1. 8 tests/src/Kernel/WorkflowsFieldContraintTest.php \Drupal\Tests\workflows_field\Kernel\WorkflowsFieldContraintTest::testNotAllowedTransition()

Test we cannot apply a valid transition unless we have permission.

File

tests/src/Kernel/WorkflowsFieldContraintTest.php, line 63

Class

WorkflowsFieldContraintTest
Tests the field constraints.

Namespace

Drupal\Tests\workflows_field\Kernel

Code

public function testNotAllowedTransition() {
  $node = Node::create([
    'title' => 'Foo',
    'type' => 'project',
    'field_status' => 'in_discussion',
  ]);
  $node
    ->save();
  $node->field_status->value = 'approved';
  $violations = $node
    ->validate();
  $this
    ->assertCount(1, $violations);
  $this
    ->assertEquals('You do not have sufficient permissions to use the <em class="placeholder">Approved Project</em> transition.', $violations[0]
    ->getMessage());
}