function EditLoadingTest::testUserWithoutPermission

Test the loading of Edit when a user doesn't have access to it.

File

drupal/core/modules/edit/lib/Drupal/edit/Tests/EditLoadingTest.php, line 74
Contains \Drupal\edit\Tests\EditLoadingTest.

Class

EditLoadingTest
Tests loading of Edit and lazy-loading of in-place editors.

Namespace

Drupal\edit\Tests

Code

function testUserWithoutPermission() {
  $this
    ->drupalLogin($this->author_user);
  $this
    ->drupalGet('node/1');

  // Settings, library and in-place editors.
  $settings = $this
    ->drupalGetSettings();
  $this
    ->assertFalse(isset($settings['edit']), 'Edit settings do not exist.');
  $this
    ->assertFalse(isset($settings['ajaxPageState']['js']['core/modules/edit/js/edit.js']), 'Edit library not loaded.');
  $this
    ->assertFalse(isset($settings['ajaxPageState']['js']['core/modules/edit/js/createjs/editingWidgets/formwidget.js']), "'form' in-place editor not loaded.");

  // HTML annotation must always exist (to not break the render cache).
  $this
    ->assertRaw('data-edit-entity="node/1"');
  $this
    ->assertRaw('data-edit-id="node/1/body/und/full"');

  // Retrieving the metadata should result in an empty 403 response.
  $response = $this
    ->retrieveMetadata(array(
    'node/1/body/und/full',
  ));
  $this
    ->assertIdentical('{}', $response);
  $this
    ->assertResponse(403);
}