You are here

public function EntityEmbedDialogTest::testEntityEmbedDialog in Entity Embed 7.3

Tests the entity embed dialog.

File

./entity_embed.test, line 118
Test integration for the entity_embed module.

Class

EntityEmbedDialogTest
Tests the entity_embed dialog controller and route.

Code

public function testEntityEmbedDialog() {

  // Ensure that the route is not accessible without specifying all the
  // parameters.
  $this
    ->getEmbedDialog();
  $this
    ->assertResponse(404, 'Embed dialog is not accessible without specifying filter format and embed button.');
  $this
    ->getEmbedDialog('custom_format');
  $this
    ->assertResponse(404, 'Embed dialog is not accessible without specifying embed button.');

  // Ensure that the route is not accessible with an invalid embed button.
  $this
    ->getEmbedDialog('custom_format', 'invalid_button');
  $this
    ->assertResponse(404, 'Embed dialog is not accessible without specifying filter format and embed button.');

  // Ensure that the route is not accessible with text format without the
  // button configured.
  $this
    ->getEmbedDialog('plain_text', 'node');
  $this
    ->assertResponse(403, 'Embed dialog is not accessible with a filter that does not have an editor configuration.');

  // Add an empty configuration for the plain_text editor configuration.
  $plain_text_format = filter_format_load('plain_text');
  $plain_text_format->editor = 'ckeditor';
  $plain_text_format->editor_settings = array();
  filter_format_save($plain_text_format);
  $this
    ->getEmbedDialog('plain_text', 'node');
  $this
    ->assertResponse(403, 'Embed dialog is not accessible with a filter that does not have the embed button assigned to it.');

  // Ensure that the route is accessible with a valid embed button.
  // 'Node' embed button is provided by default by the module and hence the
  // request must be successful.
  $this
    ->getEmbedDialog('custom_format', 'node');
  $this
    ->assertResponse(200, 'Embed dialog is accessible with correct filter format and embed button.');

  // Ensure form structure of the 'select' step and submit form.
  $this
    ->assertFieldByName('attributes[data-entity-id]', '', 'Entity ID/UUID field is present.');

  // $edit = ['attributes[data-entity-id]' => $this->node->id()];
  // $this->drupalPostAjaxForm(NULL, $edit, 'op');
  // Ensure form structure of the 'embed' step and submit form.
  // $this->assertFieldByName('attributes[data-entity-embed-display]', 'Entity Embed Display plugin field is present.');
}