You are here

public function UpdatePathTest::testUpdatePath in Entity Reference Hierarchy 8.2

Same name and namespace in other branches
  1. 3.x modules/entity_hierarchy_workbench_access/tests/src/Functional/UpdatePathTest.php \Drupal\Tests\entity_hierarchy_workbench_access\Functional\UpdatePathTest::testUpdatePath()

Tests entity_hierarchy_workbench_access_workbench_access_scheme_update_alter.

File

modules/entity_hierarchy_workbench_access/tests/src/Functional/UpdatePathTest.php, line 27

Class

UpdatePathTest
Defines a class for testing the update path to scheme based access.

Namespace

Drupal\Tests\entity_hierarchy_workbench_access\Functional

Code

public function testUpdatePath() {
  if (Semver::satisfies(\Drupal::VERSION, '~9')) {
    $this
      ->markTestSkipped('This test is only for Drupal 8');
  }
  $expected_fields = \Drupal::config('workbench_access.settings')
    ->get('parents');
  $expected_bundles = array_keys(\Drupal::config('workbench_access.settings')
    ->get('fields')['node']);
  $this
    ->runUpdates();

  /** @var \Drupal\workbench_access\Entity\AccessSchemeInterface $scheme */
  $scheme = $this->container
    ->get('entity_type.manager')
    ->getStorage('access_scheme')
    ->load('default');
  $config = $scheme
    ->getAccessScheme()
    ->getConfiguration();
  $this
    ->assertEquals($expected_fields, $config['boolean_fields']);
  $this
    ->assertEquals($expected_bundles, $config['bundles']);
  $this
    ->drupalLogin($this->rootUser);
  $this
    ->drupalGet($scheme
    ->toUrl('edit-form'));
  $assert = $this
    ->assertSession();
  $assert
    ->fieldExists('scheme_settings[bundles][page]');
  $assert
    ->checkboxChecked('scheme_settings[bundles][page]');
}