You are here

function SkinrPanelsTestCase::testPanelsDatabase in Skinr 8.2

Same name and namespace in other branches
  1. 7.2 skinr_panels/tests/skinr_panels.test \SkinrPanelsTestCase::testPanelsDatabase()

Tests panels plugin.

File

skinr_panels/tests/skinr_panels.test, line 107
Tests for the Skinr Panels module.

Class

SkinrPanelsTestCase
Tests UI functionality for Panels plugin.

Code

function testPanelsDatabase() {

  // Create a simple panel node.
  $node = $this
    ->drupalCreateNode(array(
    'type' => 'panel',
    'panels_node' => array(
      'layout' => 'onecol',
      'css_id' => '',
      'pipeline' => 'standard',
    ),
  ));

  // Add a block to our panel node.
  $display = panels_load_display($node->panels_node['did']);
  $pane = panels_new_pane('block', 'system-user-menu', TRUE);
  $display
    ->add_pane($pane, 'middle');
  $this
    ->assertTrue(panels_save_display($display), 'Block was successfully added to panel node.');

  // Go to node.
  $uri = entity_uri('node', $node);
  $this
    ->drupalGet($uri['path']);

  // Make sure our contextual link appears on the page.
  $this
    ->assertLinkByHref('admin/structure/skinr/edit/panels/pane__' . $pane->uuid . '/configure', 0, 'Contexual link to edit pane\'s skin configuration on panel node was found.');

  // Test panels pages.
  // Save page to DB.
  $task = page_manager_get_task('page');
  $handler = page_manager_load_task_handler($task, 'skinr_panels_test', 'page_skinr_panels_test_panel_context');
  page_manager_save_task_handler($handler);

  // Go to panel page.
  $this
    ->drupalGet('skinr-panels-test-panel');

  // Make sure our contextual link appears on the page.
  $this
    ->assertLinkByHref('admin/structure/skinr/edit/panels/pane__295dc791-d2a3-4f67-82e4-77c0b5ad671f/configure', 0, "Contexual link to edit pane's skin configuration on panel page (stored in DB) was found.");

  // Test mini panels.
  // Save mini panel to DB.
  $mini = panels_mini_load('skinr_panels_test_mini_panel');
  panels_mini_save($mini);

  // Add the mini block to the sidebar.
  $default_theme = variable_get('theme_default', 'bartik');
  db_merge('block')
    ->key(array(
    'theme' => $default_theme,
    'module' => 'panels_mini',
    'delta' => 'skinr_panels_test_mini_panel',
  ))
    ->fields(array(
    'status' => 1,
    'region' => 'sidebar_first',
    'pages' => '',
  ))
    ->execute();

  // Go front page.
  $this
    ->drupalGet('');

  // Make sure our contextual link appears on the page.
  $this
    ->assertLinkByHref('admin/structure/skinr/edit/panels/pane__c9bf0f8f-e48a-42d7-9a38-7a6760791765/configure', 0, 'Contexual link to edit pane\'s skin configuration on mini panel (stored in DB) was found.');

  // Make sure this panel's options are returned.
  $this
    ->drupalGet('admin/structure/skinr/add');
  $this
    ->assertOptionExists('element', 'pane__' . $pane->uuid, 'Panel pane was returned by panels_skinr_ui_element_options().');

  // Test the returned element title.
  $skin = (object) array(
    'theme' => $default_theme,
    'module' => 'panels',
    'element' => 'pane__295dc791-d2a3-4f67-82e4-77c0b5ad671f',
    'skin' => 'skinr_ui_test_bgcolor',
    'options' => array(
      'bgcolor_red',
    ),
    'status' => 1,
  );
  skinr_skin_save($skin);
  $title = skinr_invoke_all('skinr_ui_element_title', $skin->module, $skin->element, $skin->theme);
  $title = reset($title);
  $this
    ->verbose($title);
  $this
    ->assertEqual($title, 'Pane <em class="placeholder">295dc791-d2a3-4f67-82e4-77c0b5ad671f</em> on <em class="placeholder">Panels test page</em>', 'Panel title was returned.');
}