function EditIntegrationTest::testGetUntransformedTextCommand

Tests GetUntransformedTextCommand AJAX command.

File

drupal/core/modules/editor/lib/Drupal/editor/Tests/EditIntegrationTest.php, line 181
Contains \Drupal\editor\Tests\EditorIntegrationTest.

Class

EditIntegrationTest
Tests Edit module integration (Editor module's inline editing support).

Namespace

Drupal\editor\Tests

Code

function testGetUntransformedTextCommand() {

  // Create an entity with values for the field.
  $this->entity = entity_create('entity_test', array());
  $this->entity->{$this->field_name}->value = 'Test';
  $this->entity->{$this->field_name}->format = 'full_html';
  $this->entity
    ->save();
  $entity = entity_load('entity_test', $this->entity
    ->id());

  // Verify AJAX response.
  $controller = new EditorController();
  $request = new Request();
  $response = $controller
    ->getUntransformedText($entity, $this->field_name, Language::LANGCODE_NOT_SPECIFIED, 'default');
  $expected = array(
    array(
      'command' => 'editorGetUntransformedText',
      'data' => 'Test',
    ),
  );
  $this
    ->assertEqual(drupal_json_encode($expected), $response
    ->prepare($request)
    ->getContent(), 'The GetUntransformedTextCommand AJAX command works correctly.');
}