123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <?php
- /**
- * @file
- * Some rudimentary tests for entity handling, will be overridden by others.
- */
- abstract class PanelsEntityViewWebTestCase extends DrupalWebTestCase {
- /**
- * Admin user.
- *
- * @var \StdClass
- */
- protected $adminUser;
- /**
- * The task handler used for managing a specific entity type.
- *
- * @var \StdClass
- */
- protected $view_name = 'node_view';
- /**
- * The label used for this entity's task handler.
- *
- * @var \StdClass
- */
- protected $view_label = 'Node template';
- /**
- * {@inheritdoc}
- */
- function setUp(array $modules = array()) {
- $modules[] = 'panels';
- $modules[] = 'page_manager';
- parent::setUp($modules);
- $permissions = array(
- // Allow the user to access the Page Manager admin page.
- 'use page manager',
- // Basic permissions for the module.
- 'use panels dashboard',
- // General admin access.
- 'access administration pages',
- );
- // Reset the static variable used to identify permissions, otherwise it's
- // possible the permissions check in drupalCreateUser will fail.
- $this->checkPermissions(array(), TRUE);
- cache_clear_all();
- // Create the admin user.
- $this->adminUser = $this->drupalCreateUser($permissions);
- }
- /**
- * Ensure that the {ENTITY}_view toggle works correctly.
- */
- 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'));
- }
- }
|