You are here

function PanelsEntityViewWebTestCase::testToggle in Panels 7.3

Ensure that the {ENTITY}_view toggle works correctly.

File

tests/PanelsEntityViewWebTestCase.test, line 63
Some rudimentary tests for entity handling, will be overridden by others.

Class

PanelsEntityViewWebTestCase
@file Some rudimentary tests for entity handling, will be overridden by others.

Code

function testToggle() {

  // Log in as the admin user.
  $this
    ->drupalLogin($this->adminUser);

  // Load the Panels dashboard.
  $this
    ->drupalGet('admin/structure/panels');
  $this
    ->assertResponse(200, 'Loaded the main Panels admin page.');

  // Confirm that the Node View task handler is disabled.
  $this
    ->assertText(t($this->view_label));
  $this
    ->assertLinkByHref(url('admin/structure/pages/edit/' . $this->view_name, array(
    'absolute' => FALSE,
  )));
  $xpath = $this
    ->xpath("//tr[contains(@class,:tr)]/td/div/div/ul/li[contains(@class,:li)]/a", array(
    ':tr' => 'page-task-' . $this->view_name,
    ':li' => 'first',
  ));
  $this
    ->assertEqual($xpath[0][0], t('Enable'));

  // Set the Node View handler to "off".
  variable_set('page_manager_' . $this->view_name . '_disabled', TRUE);

  // Load the Panels dashboard again.
  $this
    ->drupalGet('admin/structure/panels');
  $this
    ->assertResponse(200, 'Loaded the main Panels admin page.');

  // Confirm that the Node View task handler is still disabled.
  $this
    ->assertText(t($this->view_label));
  $this
    ->assertNoLinkByHref(url('admin/structure/pages/nojs/disable/' . $this->view_name, array(
    'absolute' => FALSE,
  )));
  $xpath = $this
    ->xpath("//tr[contains(@class,:tr)]/td/div/div/ul/li[contains(@class,:li)]/a", array(
    ':tr' => 'page-task-' . $this->view_name,
    ':li' => 'first',
  ));
  $this
    ->assertEqual($xpath[0][0], t('Enable'));

  // Set the Node View handler to "on".
  variable_set('page_manager_' . $this->view_name . '_disabled', FALSE);

  // Load the Panels dashboard again.
  $this
    ->drupalGet('admin/structure/panels');
  $this
    ->assertResponse(200, 'Loaded the main Panels admin page.');

  // Confirm that the Node View task handler is now enabled.
  $this
    ->assertLinkByHref(url('admin/structure/pages/nojs/disable/' . $this->view_name, array(
    'absolute' => FALSE,
  )));
  $xpath = $this
    ->xpath("//tr[contains(@class,:tr)]/td/div/div/ul/li[contains(@class,:li)]/a", array(
    ':tr' => 'page-task-' . $this->view_name,
    ':li' => 'last',
  ));
  $this
    ->assertEqual($xpath[0][0], t('Disable'));
}