You are here

protected function WorkbenchAccessTestTrait::assertCreatingAnAccessSchemeAsAdmin in Workbench Access 8

Assert that admin can create an access scheme.

Parameters

string $scheme_id: Scheme plugin ID.

Return value

\Drupal\workbench_access\Entity\AccessSchemeInterface Created scheme.

2 calls to WorkbenchAccessTestTrait::assertCreatingAnAccessSchemeAsAdmin()
MenuSchemeUITest::testSchemeUi in tests/src/Functional/MenuSchemeUITest.php
Tests scheme UI.
TaxonomySchemeUITest::testSchemeUi in tests/src/Functional/TaxonomySchemeUITest.php
Tests scheme UI.

File

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

Class

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

Namespace

Drupal\Tests\workbench_access\Traits

Code

protected function assertCreatingAnAccessSchemeAsAdmin($scheme_id = 'taxonomy') {
  $this
    ->drupalLogin($this->admin);
  $this
    ->drupalGet(Url::fromRoute('entity.access_scheme.collection'));
  $assert = $this
    ->assertSession();
  $assert
    ->statusCodeEquals(200);
  $this
    ->clickLink('Add Access scheme');
  $this
    ->submitForm([
    'label' => 'Section',
    'plural_label' => 'Sections',
    'id' => 'editorial_section',
    'scheme' => $scheme_id,
  ], 'Save');

  /** @var \Drupal\workbench_access\Entity\AccessSchemeInterface $scheme */
  $scheme = $this
    ->loadUnchangedScheme('editorial_section');
  $this
    ->assertEquals('Section', $scheme
    ->label());
  $this
    ->assertEquals('Sections', $scheme
    ->getPluralLabel());
  $this
    ->assertEquals($scheme
    ->toUrl('edit-form')
    ->setAbsolute()
    ->toString(), $this
    ->getSession()
    ->getCurrentUrl());
  return $scheme;
}