skinr_panels.test 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <?php
  2. /**
  3. * @file
  4. * Tests for the Skinr Panels module.
  5. */
  6. /**
  7. * Tests UI functionality for Panels plugin.
  8. */
  9. class SkinrPanelsTestCase extends DrupalWebTestCase {
  10. public static function getInfo() {
  11. return array(
  12. 'name' => 'Plugins UI - Panels',
  13. 'description' => 'Tests Skinr UI functionality for functionality plugin from Panels.',
  14. 'dependencies' => array('ctools', 'page_manager', 'panels', 'panels_node', 'panels_mini'),
  15. 'group' => 'Skinr',
  16. );
  17. }
  18. function setUp() {
  19. parent::setUp(array('block', 'page_manager', 'panels_node', 'panels_mini', 'skinr_panels_test'));
  20. $this->admin_user = $this->drupalCreateUser(array(
  21. 'administer blocks',
  22. 'use page manager',
  23. 'administer page manager',
  24. 'create mini panels',
  25. 'administer mini panels',
  26. 'access contextual links',
  27. 'administer skinr',
  28. 'edit skin settings',
  29. 'edit advanced skin settings',
  30. 'bypass node access',
  31. ));
  32. $this->drupalLogin($this->admin_user);
  33. }
  34. /**
  35. * Tests panels plugin.
  36. *
  37. * @todo The below test doesn't work due to CTools/Panels not passing along
  38. * enough data to create unique element ids when panels are in code. Skinr
  39. * currently doesn't support panels in code.
  40. */
  41. function xtestPanelsDefault() {
  42. // Test panels pages.
  43. // Go to panel page.
  44. $this->drupalGet('skinr-panels-test-panel');
  45. // Make sure our contextual link appears on the page.
  46. $this->assertLinkByHref('admin/structure/skinr/edit/nojs/panels/pane__1__1/configure', 0, "Contexual link to edit pane's skin configuration on panel page (stored in code) was found.");
  47. $this->drupalGet('admin/structure/mini-panels');
  48. // Test mini panels.
  49. // Add the mini block to the sidebar.
  50. $default_theme = variable_get('theme_default', 'bartik');
  51. db_merge('block')
  52. ->key(array(
  53. 'theme' => $default_theme,
  54. 'module' => 'panels_mini',
  55. 'delta' => 'skinr_panels_test_mini_panel',
  56. ))
  57. ->fields(array(
  58. 'status' => 1,
  59. 'region' => 'sidebar_first',
  60. 'pages' => '',
  61. ))
  62. ->execute();
  63. // Go front page.
  64. $this->drupalGet('');
  65. // Make sure our contextual link appears on the page.
  66. // @todo Is there a better way to determine did and pid used for this panel?
  67. $this->assertLinkByHref('admin/structure/skinr/edit/nojs/panels/pane__2__2/configure', 0, 'Contexual link to edit pane\'s skin configuration on mini panel (stored in code) was found.');
  68. }
  69. /**
  70. * Tests panels plugin.
  71. */
  72. function testPanelsDatabase() {
  73. // Create a simple panel node.
  74. $node = $this->drupalCreateNode(array(
  75. 'type' => 'panel',
  76. 'panels_node' => array(
  77. 'layout' => 'onecol',
  78. 'css_id' => '',
  79. 'pipeline' => 'standard',
  80. ),
  81. ));
  82. // Add a block to our panel node.
  83. $display = panels_load_display($node->panels_node['did']);
  84. $pane = panels_new_pane('block', 'system-user-menu', TRUE);
  85. $display->add_pane($pane, 'middle');
  86. $this->assertTrue(panels_save_display($display), 'Block was successfully added to panel node.');
  87. // Go to node.
  88. $uri = entity_uri('node', $node);
  89. $this->drupalGet($uri['path']);
  90. // Make sure our contextual link appears on the page.
  91. // @todo Is there a better way to determine did and pid used for this panel?
  92. $this->assertLinkByHref('admin/structure/skinr/edit/nojs/panels/pane__1__1/configure', 0, 'Contexual link to edit pane\'s skin configuration on panel node was found.');
  93. // Test panels pages.
  94. // Save page to DB.
  95. $task = page_manager_get_task('page');
  96. $handler = page_manager_load_task_handler($task, 'skinr_panels_test', 'page_skinr_panels_test_panel_context');
  97. page_manager_save_task_handler($handler);
  98. // Go to panel page.
  99. $this->drupalGet('skinr-panels-test-panel');
  100. // Make sure our contextual link appears on the page.
  101. $this->assertLinkByHref('admin/structure/skinr/edit/nojs/panels/pane__2__2/configure', 0, "Contexual link to edit pane's skin configuration on panel page (stored in DB) was found.");
  102. // Test mini panels.
  103. // Save mini panel to DB.
  104. $mini = panels_mini_load('skinr_panels_test_mini_panel');
  105. panels_mini_save($mini);
  106. // Add the mini block to the sidebar.
  107. $default_theme = variable_get('theme_default', 'bartik');
  108. db_merge('block')
  109. ->key(array(
  110. 'theme' => $default_theme,
  111. 'module' => 'panels_mini',
  112. 'delta' => 'skinr_panels_test_mini_panel',
  113. ))
  114. ->fields(array(
  115. 'status' => 1,
  116. 'region' => 'sidebar_first',
  117. 'pages' => '',
  118. ))
  119. ->execute();
  120. // Go front page.
  121. $this->drupalGet('');
  122. // Make sure our contextual link appears on the page.
  123. // @todo Is there a better way to determine did and pid used for this panel?
  124. $this->assertLinkByHref('admin/structure/skinr/edit/nojs/panels/pane__3__3/configure', 0, 'Contexual link to edit pane\'s skin configuration on mini panel (stored in DB) was found.');
  125. }
  126. }