You are here

public function QuickEditIntegrationLoadingTest::testUserWithPermission in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/editor/src/Tests/QuickEditIntegrationLoadingTest.php \Drupal\editor\Tests\QuickEditIntegrationLoadingTest::testUserWithPermission()

Test loading of untransformed text when a user does have access to it.

File

core/modules/editor/src/Tests/QuickEditIntegrationLoadingTest.php, line 101
Contains \Drupal\editor\Tests\QuickEditIntegrationLoadingTest.

Class

QuickEditIntegrationLoadingTest
Tests Quick Edit module integration endpoints.

Namespace

Drupal\editor\Tests

Code

public function testUserWithPermission() {
  $user = $this
    ->drupalCreateUser(array_merge(static::$basicPermissions, array(
    'edit any article content',
    'access in-place editing',
  )));
  $this
    ->drupalLogin($user);
  $this
    ->drupalGet('node/1');

  // Ensure the text is transformed.
  $this
    ->assertRaw('<p>Do you also love Drupal?</p><figure role="group" class="caption caption-img"><img src="druplicon.png" /><figcaption>Druplicon</figcaption></figure>');
  $response = $this
    ->drupalPost('editor/' . 'node/1/body/en/full', 'application/vnd.drupal-ajax', array());
  $this
    ->assertResponse(200);
  $ajax_commands = Json::decode($response);
  $this
    ->assertIdentical(1, count($ajax_commands), 'The untransformed text POST request results in one AJAX command.');
  $this
    ->assertIdentical('editorGetUntransformedText', $ajax_commands[0]['command'], 'The first AJAX command is an editorGetUntransformedText command.');
  $this
    ->assertIdentical('<p>Do you also love Drupal?</p><img src="druplicon.png" data-caption="Druplicon" />', $ajax_commands[0]['data'], 'The editorGetUntransformedText command contains the expected data.');
}