You are here

public function EntityStateChangeValidationTest::transitionAccessValidationTestCases in Workbench Moderation 8

Test cases for access validation.

File

tests/src/Kernel/EntityStateChangeValidationTest.php, line 243

Class

EntityStateChangeValidationTest
@coversDefaultClass \Drupal\workbench_moderation\Plugin\Validation\Constraint\ModerationStateValidator @group workbench_moderation

Namespace

Drupal\Tests\workbench_moderation\Kernel

Code

public function transitionAccessValidationTestCases() {
  return [
    'Invalid transition, no permissions validated' => [
      [],
      'draft',
      'archived',
      [
        'Invalid state transition from <em class="placeholder">Draft</em> to <em class="placeholder">Archived</em>',
      ],
    ],
    'Valid transition, missing permission' => [
      [],
      'draft',
      '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 draft_published transition',
      ],
      'draft',
      'published',
      [],
    ],
    'Valid transition, granted draft permission' => [
      [
        'use draft_draft transition',
      ],
      'draft',
      'draft',
      [],
    ],
    'Valid transition, incorrect permission granted' => [
      [
        'use draft_draft transition',
      ],
      'draft',
      'published',
      [
        'You do not have access to transition from <em class="placeholder">Draft</em> to <em class="placeholder">Published</em>',
      ],
    ],
    'Non-draft default state, incorrect permission granted' => [
      [
        'use draft_draft transition',
      ],
      'archived',
      'published',
      [
        'You do not have access to transition from <em class="placeholder">Archived</em> to <em class="placeholder">Published</em>',
      ],
    ],
    'Non-draft default state, correct permission granted' => [
      [
        'use archived_published transition',
      ],
      'archived',
      'published',
      [],
    ],
    'Non-draft default state, invalid transition' => [
      [
        'use published_archived transition',
      ],
      'archived',
      'draft',
      [
        'Invalid state transition from <em class="placeholder">Archived</em> to <em class="placeholder">Draft</em>',
      ],
    ],
  ];
}