You are here

function EmbedButtonAdminTest::testEmbedButtonAdmin in Entity Embed 7.2

Same name and namespace in other branches
  1. 7.3 entity_embed.test \EmbedButtonAdminTest::testEmbedButtonAdmin()
  2. 7 entity_embed.test \EmbedButtonAdminTest::testEmbedButtonAdmin()

Tests the embed_button administration functionality.

File

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

Class

EmbedButtonAdminTest
Tests the administrative UI.

Code

function testEmbedButtonAdmin() {
  $this
    ->drupalGet('admin/config/content/embed-button');
  $this
    ->assertResponse(403, 'User without admin permissions are not able to visit the configuration page.');

  // Swtich to admin user.
  $this
    ->drupalLogin($this->adminUser);
  $this
    ->drupalGet('admin/config/content/embed-button');
  $this
    ->assertResponse(200, 'User without admin permissions is able to visit the configuration page.');
  $this
    ->assertText('Node', 'Node embed_button entity exists by default.');
  $this
    ->assertText('node', 'Node embed_button entity exists by default.');

  // Add embed button.
  $this
    ->clickLink('Add');
  $button_id = drupal_strtolower($this
    ->randomName());
  $name = $this
    ->randomName();
  $edit = array(
    'admin_title' => $name,
    'name' => $button_id,
    'entity_type' => 'node',
    'button_label' => $name,
  );
  $this
    ->drupalPost(NULL, $edit, t('Choose'));
  $this
    ->drupalPost(NULL, $edit, t('Save'));

  // Ensure that the newly created button exists.
  $this
    ->drupalGet('admin/config/content/embed-button/list/' . $button_id);
  $this
    ->assertResponse(200, 'Added embed button exists.');

  // Ensure that the newly created button is listed.
  $this
    ->drupalGet('admin/config/content/embed-button');
  $this
    ->assertText($name, 'Test embed_button appears on the list page');

  // Edit embed button.
  $this
    ->drupalGet('admin/config/content/embed-button/list/' . $button_id . '/edit');
  $new_name = drupal_strtolower($this
    ->randomName());
  $edit = array(
    'admin_title' => $new_name,
    'button_label' => $new_name,
  );
  $this
    ->drupalPost(NULL, $edit, t('Save'));

  // Ensure that name and button_label has been changed.
  $this
    ->drupalGet('admin/config/content/embed-button');
  $this
    ->assertText($new_name, 'New label appears on the list page');
  $this
    ->assertNoText($name, 'Old label does not appears on the list page');

  // Delete embed button.
  $this
    ->drupalGet('admin/config/content/embed-button/list/' . $button_id . '/delete');
  $this
    ->drupalPost(NULL, array(), t('Delete'));

  // Ensure that the deleted embed button no longer exists.
  $this
    ->drupalGet('admin/config/content/embed-button/list/' . $button_id);
  $this
    ->assertResponse(404, 'Deleted embed button no longer exists.');

  // Ensure that the deleted button is no longer listed.
  $this
    ->drupalGet('admin/config/content/embed-button');
  $this
    ->assertNoText($name, 'Test embed_button does not appears on the list page');
}