You are here

public function PanelizerIpeTest::testAdminUser in Panelizer 8.5

Same name and namespace in other branches
  1. 8.4 tests/src/Functional/PanelizerIpeTest.php \Drupal\Tests\panelizer\Functional\PanelizerIpeTest::testAdminUser()

Test that the IPE functionality as user 1, which should cover all options.

File

tests/src/Functional/PanelizerIpeTest.php, line 95

Class

PanelizerIpeTest
Confirm that the IPE functionality works.

Namespace

Drupal\Tests\panelizer\Functional

Code

public function testAdminUser() {

  // Create a test node.
  $node = $this
    ->createTestNode();

  // Log in as user 1.
  $this
    ->loginUser1();

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

  // Confirm the JSON Drupal settings are appropriate.
  $drupalSettings = NULL;
  $matches = [];
  if (preg_match('@<script type="application/json" data-drupal-selector="drupal-settings-json">([^<]*)</script>@', $this
    ->getRawContent(), $matches)) {
    $drupalSettings = Json::decode($matches[1]);
    $this
      ->verbose('<pre>' . print_r($drupalSettings, TRUE) . '</pre>');
  }
  $this
    ->assertNotNull($drupalSettings);
  if (!empty($drupalSettings)) {
    $this
      ->assertArrayHasKey('panels_ipe', $drupalSettings);
    $this
      ->assertArrayHasKey('regions', $drupalSettings['panels_ipe']);
    $this
      ->assertArrayHasKey('layout', $drupalSettings['panels_ipe']);
    $this
      ->assertArrayHasKey('user_permission', $drupalSettings['panels_ipe']);
    $this
      ->assertArrayHasKey('panels_display', $drupalSettings['panels_ipe']);
    $this
      ->assertArrayHasKey('unsaved', $drupalSettings['panels_ipe']);
    $this
      ->assertArrayHasKey('panelizer', $drupalSettings);
    $this
      ->assertArrayHasKey('entity', $drupalSettings['panelizer']);
    $this
      ->assertArrayHasKey('entity_type_id', $drupalSettings['panelizer']['entity']);
    $this
      ->assertEqual($drupalSettings['panelizer']['entity']['entity_type_id'], 'node');
    $this
      ->assertArrayHasKey('entity_id', $drupalSettings['panelizer']['entity']);
    $this
      ->assertEqual($drupalSettings['panelizer']['entity']['entity_id'], $node
      ->id());
    $this
      ->assertArrayHasKey('user_permission', $drupalSettings['panelizer']);
    $this
      ->assertArrayHasKey('revert', $drupalSettings['panelizer']['user_permission']);
    $this
      ->assertArrayHasKey('save_default', $drupalSettings['panelizer']['user_permission']);
  }
}