You are here

public function EntityStateChangeValidationTest::transitionAccessValidationTestCases in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/content_moderation/tests/src/Kernel/EntityStateChangeValidationTest.php \Drupal\Tests\content_moderation\Kernel\EntityStateChangeValidationTest::transitionAccessValidationTestCases()

Test cases for ::testTransitionAccessValidation.

File

core/modules/content_moderation/tests/src/Kernel/EntityStateChangeValidationTest.php, line 360

Class

EntityStateChangeValidationTest
@coversDefaultClass \Drupal\content_moderation\Plugin\Validation\Constraint\ModerationStateConstraintValidator @group content_moderation

Namespace

Drupal\Tests\content_moderation\Kernel

Code

public function transitionAccessValidationTestCases() {
  return [
    'Invalid transition, no permissions validated' => [
      [],
      'archived',
      [
        'Invalid state transition from <em class="placeholder">Draft</em> to <em class="placeholder">Archived</em>',
      ],
    ],
    'Valid transition, missing permission' => [
      [],
      'published',
      [
        'You do not have access to transition from <em class="placeholder">Draft</em> to <em class="placeholder">Published</em>',
      ],
    ],
    'Valid transition, granted published permission' => [
      [
        'use editorial transition publish',
      ],
      'published',
      [],
    ],
    'Valid transition, granted draft permission' => [
      [
        'use editorial transition create_new_draft',
      ],
      'draft',
      [],
    ],
    'Valid transition, incorrect permission granted' => [
      [
        'use editorial transition create_new_draft',
      ],
      'published',
      [
        'You do not have access to transition from <em class="placeholder">Draft</em> to <em class="placeholder">Published</em>',
      ],
    ],
    // Test with an additional state and set of transitions, since the
    // "published" transition can start from either "draft" or "published", it
    // does not capture bugs that fail to correctly distinguish the initial
    // workflow state from the set state of a new entity.
    'Valid transition, granted foo permission' => [
      [
        'use editorial transition draft_to_foo',
      ],
      'foo',
      [],
    ],
    'Valid transition, incorrect  foo permission granted' => [
      [
        'use editorial transition foo_to_foo',
      ],
      'foo',
      [
        'You do not have access to transition from <em class="placeholder">Draft</em> to <em class="placeholder">Foo</em>',
      ],
    ],
  ];
}