/**
  * Tests GetUntransformedTextCommand AJAX command.
  */
 public function testGetUntransformedTextCommand()
 {
     // Create an entity with values for the field.
     $entity = entity_create('entity_test');
     $entity->{$this->fieldName}->value = 'Test';
     $entity->{$this->fieldName}->format = 'full_html';
     $entity->save();
     $entity = entity_load('entity_test', $entity->id());
     // Verify AJAX response.
     $controller = new EditorController();
     $request = new Request();
     $response = $controller->getUntransformedText($entity, $this->fieldName, LanguageInterface::LANGCODE_NOT_SPECIFIED, 'default');
     $expected = array(array('command' => 'editorGetUntransformedText', 'data' => 'Test'));
     $ajax_response_attachments_processor = \Drupal::service('ajax_response.attachments_processor');
     $subscriber = new AjaxResponseSubscriber($ajax_response_attachments_processor);
     $event = new FilterResponseEvent(\Drupal::service('http_kernel'), $request, HttpKernelInterface::MASTER_REQUEST, $response);
     $subscriber->onResponse($event);
     $this->assertEqual(Json::encode($expected), $response->getContent(), 'The GetUntransformedTextCommand AJAX command works correctly.');
 }
 /**
  * Tests GetUntransformedTextCommand AJAX command.
  */
 public function testGetUntransformedTextCommand()
 {
     // Create an entity with values for the field.
     $this->entity = entity_create('entity_test');
     $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, LanguageInterface::LANGCODE_NOT_SPECIFIED, 'default');
     $expected = array(array('command' => 'editorGetUntransformedText', 'data' => 'Test'));
     $this->assertEqual(Json::encode($expected), $response->prepare($request)->getContent(), 'The GetUntransformedTextCommand AJAX command works correctly.');
 }