You are here

public function WorkbenchAccessTestTrait::setUpTaxonomyScheme in Workbench Access 8

Sets up a taxonomy scheme for a given node type.

Parameters

\Drupal\node\Entity\NodeType $node_type: Node type to set it up for.

\Drupal\taxonomy\Entity\Vocabulary $vocab: The vocab to use for the scheme.

string $id: Scheme ID.

Return value

\Drupal\workbench_access\Entity\AccessSchemeInterface Created scheme.

10 calls to WorkbenchAccessTestTrait::setUpTaxonomyScheme()
AccessByRoleFormTest::testAccessByRoleForm in tests/src/Functional/AccessByRoleFormTest.php
Tests that the correct roles are displayed on the access by role form.
AccessByUserFormTest::testAccessByUserForm in tests/src/Functional/AccessByUserFormTest.php
Tests that the correct users are displayed on the access by user form.
AccessCacheTest::testNodeEdit in tests/src/Functional/AccessCacheTest.php
Tests that the user can edit the node when allowed.
AssignUserFormTest::testAssignUserForm in tests/src/Functional/AssignUserFormTest.php
Tests that the AssignUserForm works correctly.
ConfigDependenciesTest::setUp in tests/src/Kernel/ConfigDependenciesTest.php

... See full list

File

tests/src/Traits/WorkbenchAccessTestTrait.php, line 160

Class

WorkbenchAccessTestTrait
Contains helper classes for tests to set up various configuration.

Namespace

Drupal\Tests\workbench_access\Traits

Code

public function setUpTaxonomyScheme(NodeType $node_type, Vocabulary $vocab, $id = 'editorial_section') {
  $scheme = AccessScheme::create([
    'id' => $id,
    'label' => ucfirst(str_replace('_', ' ', $id)),
    'plural_label' => ucfirst(str_replace('_', ' ', $id)) . 's',
    'scheme' => 'taxonomy',
    'scheme_settings' => [
      'vocabularies' => [
        $vocab
          ->id(),
      ],
      'fields' => [
        [
          'entity_type' => 'node',
          'field' => WorkbenchAccessManagerInterface::FIELD_NAME,
          'bundle' => $node_type
            ->id(),
        ],
      ],
    ],
  ]);
  $scheme
    ->save();
  return $scheme;
}