You are here

protected function PanelizerIpeTest::setupPermissionTests in Panelizer 8.3

Do the necessary setup work for the individual permissions tests.

Parameters

array $perms: Any additiona permissions that need to be added.

obj $node: The node to test against, if none provided one will be generated.

Return value

array The full drupalSettings JSON structure in array format.

3 calls to PanelizerIpeTest::setupPermissionTests()
PanelizerIpeTest::testAdministerEntityContent in src/Tests/PanelizerIpeTest.php
@todo Confirm the 'administer panelizer $entity_type_id $bundle content' permission works.
PanelizerIpeTest::testAdministerEntityLayout in src/Tests/PanelizerIpeTest.php
@todo Confirm the 'administer panelizer $entity_type_id $bundle layout' permission works.
PanelizerIpeTest::testAdministerEntityRevert in src/Tests/PanelizerIpeTest.php
@todo Confirm the 'administer panelizer $entity_type_id $bundle revert' permission works.

File

src/Tests/PanelizerIpeTest.php, line 373

Class

PanelizerIpeTest
Confirm that the IPE functionality works.

Namespace

Drupal\panelizer\Tests

Code

protected function setupPermissionTests(array $perms, $node = NULL) {

  // Create a new user with the permissions being tested.
  $account = $this
    ->createAdminUser($perms);
  $this
    ->drupalLogin($account);

  // Make sure there's a test node to work with.
  if (empty($node)) {
    $node = $this
      ->createTestNode();
  }

  // Load the test node.
  $this
    ->drupalGet('node/' . $node
    ->id());
  $this
    ->assertResponse(200);

  // Extract the drupalSettings structure and return it.
  $drupalSettings = NULL;
  $matches = [];
  if (preg_match('@<script type="application/json" data-drupal-selector="drupal-settings-json">([^<]*)</script>@', $this->content, $matches)) {
    $drupalSettings = Json::decode($matches[1]);
    $this
      ->verbose('<pre>' . print_r($drupalSettings, TRUE) . '</pre>');
  }
  return $drupalSettings;
}