first import
This commit is contained in:
153
sites/all/modules/skinr/skinr_panels/tests/skinr_panels.test
Normal file
153
sites/all/modules/skinr/skinr_panels/tests/skinr_panels.test
Normal file
@@ -0,0 +1,153 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Tests for the Skinr Panels module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests UI functionality for Panels plugin.
|
||||
*/
|
||||
class SkinrPanelsTestCase extends DrupalWebTestCase {
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Plugins UI - Panels',
|
||||
'description' => 'Tests Skinr UI functionality for functionality plugin from Panels.',
|
||||
'dependencies' => array('ctools', 'page_manager', 'panels', 'panels_node', 'panels_mini'),
|
||||
'group' => 'Skinr',
|
||||
);
|
||||
}
|
||||
|
||||
function setUp() {
|
||||
parent::setUp(array('block', 'page_manager', 'panels_node', 'panels_mini', 'skinr_panels_test'));
|
||||
|
||||
$this->admin_user = $this->drupalCreateUser(array(
|
||||
'administer blocks',
|
||||
|
||||
'use page manager',
|
||||
'administer page manager',
|
||||
|
||||
'create mini panels',
|
||||
'administer mini panels',
|
||||
|
||||
'access contextual links',
|
||||
'administer skinr',
|
||||
'edit skin settings',
|
||||
'edit advanced skin settings',
|
||||
'bypass node access',
|
||||
));
|
||||
$this->drupalLogin($this->admin_user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests panels plugin.
|
||||
*
|
||||
* @todo The below test doesn't work due to CTools/Panels not passing along
|
||||
* enough data to create unique element ids when panels are in code. Skinr
|
||||
* currently doesn't support panels in code.
|
||||
*/
|
||||
function xtestPanelsDefault() {
|
||||
// Test panels pages.
|
||||
// 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/nojs/panels/pane__1__1/configure', 0, "Contexual link to edit pane's skin configuration on panel page (stored in code) was found.");
|
||||
|
||||
|
||||
$this->drupalGet('admin/structure/mini-panels');
|
||||
|
||||
// Test mini panels.
|
||||
// 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.
|
||||
// @todo Is there a better way to determine did and pid used for this panel?
|
||||
$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.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests panels plugin.
|
||||
*/
|
||||
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.
|
||||
// @todo Is there a better way to determine did and pid used for this panel?
|
||||
$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.');
|
||||
|
||||
|
||||
// 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/nojs/panels/pane__2__2/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.
|
||||
// @todo Is there a better way to determine did and pid used for this panel?
|
||||
$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.');
|
||||
}
|
||||
}
|
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
$page = new stdClass;
|
||||
$page->disabled = FALSE; /* Edit this to true to make a default page disabled initially */
|
||||
$page->api_version = 1;
|
||||
$page->name = 'skinr_panels_test';
|
||||
$page->task = 'page';
|
||||
$page->admin_title = 'Skinr Panels Test';
|
||||
$page->admin_description = 'Skinr Panels Test panels page.';
|
||||
$page->path = 'skinr-panels-test-panel';
|
||||
$page->access = array();
|
||||
$page->menu = array();
|
||||
$page->arguments = array();
|
||||
$page->conf = array(
|
||||
'admin_paths' => FALSE,
|
||||
);
|
||||
$page->default_handlers = array();
|
||||
$handler = new stdClass;
|
||||
$handler->disabled = FALSE; /* Edit this to true to make a default handler disabled initially */
|
||||
$handler->api_version = 1;
|
||||
$handler->name = 'page_skinr_panels_test_panel_context';
|
||||
$handler->task = 'page';
|
||||
$handler->subtask = 'skinr_panels_test';
|
||||
$handler->handler = 'panel_context';
|
||||
$handler->weight = 0;
|
||||
$handler->conf = array(
|
||||
'title' => 'Panel',
|
||||
'no_blocks' => 0,
|
||||
'pipeline' => 'standard',
|
||||
'css_id' => '',
|
||||
'css' => '',
|
||||
'contexts' => array(),
|
||||
'relationships' => array(),
|
||||
);
|
||||
$display = new panels_display;
|
||||
$display->layout = 'onecol';
|
||||
$display->layout_settings = array();
|
||||
$display->panel_settings = array(
|
||||
'style_settings' => array(
|
||||
'default' => NULL,
|
||||
'middle' => NULL,
|
||||
),
|
||||
);
|
||||
$display->cache = array();
|
||||
$display->title = '';
|
||||
$display->content = array();
|
||||
$display->panels = array();
|
||||
$pane = new stdClass;
|
||||
$pane->pid = 'new-1';
|
||||
$pane->panel = 'middle';
|
||||
$pane->type = 'block';
|
||||
$pane->subtype = 'system-user-menu';
|
||||
$pane->shown = TRUE;
|
||||
$pane->access = array();
|
||||
$pane->configuration = array(
|
||||
'override_title' => 0,
|
||||
'override_title_text' => '',
|
||||
);
|
||||
$pane->cache = array();
|
||||
$pane->style = array(
|
||||
'settings' => NULL,
|
||||
);
|
||||
$pane->css = array();
|
||||
$pane->extras = array();
|
||||
$pane->position = 0;
|
||||
$display->content['new-1'] = $pane;
|
||||
$display->panels['middle'][0] = 'new-1';
|
||||
$display->hide_title = PANELS_TITLE_FIXED;
|
||||
$display->title_pane = 'new-1';
|
||||
$handler->conf['display'] = $display;
|
||||
$page->default_handlers[$handler->name] = $handler;
|
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
$mini = new stdClass;
|
||||
$mini->disabled = FALSE;
|
||||
$mini->api_version = 1;
|
||||
$mini->name = 'skinr_panels_test_mini_panel';
|
||||
$mini->category = '';
|
||||
$mini->admin_title = 'Skinr Panels Test mini panel';
|
||||
$mini->admin_description = 'Skinr Panels Test mini panel.';
|
||||
$mini->requiredcontexts = array();
|
||||
$mini->contexts = array();
|
||||
$mini->relationships = array();
|
||||
$display = new panels_display;
|
||||
$display->layout = 'onecol';
|
||||
$display->layout_settings = array();
|
||||
$display->panel_settings = array(
|
||||
'style_settings' => array(
|
||||
'default' => NULL,
|
||||
'middle' => NULL,
|
||||
),
|
||||
);
|
||||
$display->cache = array();
|
||||
$display->title = '';
|
||||
$display->content = array();
|
||||
$display->panels = array();
|
||||
$pane = new stdClass;
|
||||
$pane->pid = 'new-1';
|
||||
$pane->panel = 'middle';
|
||||
$pane->type = 'block';
|
||||
$pane->subtype = 'system-user-menu';
|
||||
$pane->shown = TRUE;
|
||||
$pane->access = array();
|
||||
$pane->configuration = array(
|
||||
'override_title' => 0,
|
||||
'override_title_text' => '',
|
||||
);
|
||||
$pane->cache = array();
|
||||
$pane->style = array(
|
||||
'settings' => NULL,
|
||||
);
|
||||
$pane->css = array();
|
||||
$pane->extras = array();
|
||||
$pane->position = 0;
|
||||
$display->content['new-1'] = $pane;
|
||||
$display->panels['middle'][0] = 'new-1';
|
||||
$display->hide_title = PANELS_TITLE_FIXED;
|
||||
$display->title_pane = '0';
|
||||
$mini->display = $display;
|
@@ -0,0 +1,14 @@
|
||||
name = Skinr Panels Testing
|
||||
description = A test module used for testing Skinr Panels.
|
||||
package = Testing
|
||||
core = 7.x
|
||||
hidden = TRUE
|
||||
dependencies[] = skinr_panels
|
||||
dependencies[] = skinr_ui
|
||||
|
||||
; Information added by drupal.org packaging script on 2012-01-20
|
||||
version = "7.x-2.0-alpha1"
|
||||
core = "7.x"
|
||||
project = "skinr"
|
||||
datestamp = "1327086045"
|
||||
|
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Skinr Panels testing module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of hook_ctools_plugin_api().
|
||||
*/
|
||||
function skinr_panels_test_ctools_plugin_api($module, $api) {
|
||||
if (($module == 'page_manager' && $api == 'pages_default') || ($module == 'panels_mini' && $api == 'panels_default')) {
|
||||
return array('version' => 1);
|
||||
}
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Default pages.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of hook_default_page_manager_pages().
|
||||
*/
|
||||
function skinr_panels_test_default_page_manager_pages() {
|
||||
static $pages;
|
||||
|
||||
if (isset($pages)) {
|
||||
return $pages;
|
||||
}
|
||||
|
||||
$files = file_scan_directory(drupal_get_path('module', 'skinr_panels_test') . '/pages_default', '/\.inc$/');
|
||||
foreach ($files as $filepath => $file) {
|
||||
include $filepath;
|
||||
if (isset($page)) {
|
||||
$pages[$page->name] = $page;
|
||||
}
|
||||
}
|
||||
return $pages;
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* skinr_panels_test.panels_default.inc
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of hook_default_panels_mini().
|
||||
*/
|
||||
function skinr_panels_test_default_panels_mini() {
|
||||
static $minis;
|
||||
|
||||
if (isset($minis)) {
|
||||
return $minis;
|
||||
}
|
||||
|
||||
$files = file_scan_directory(drupal_get_path('module', 'skinr_panels_test') . '/panels_default', '/\.inc$/');
|
||||
foreach ($files as $filepath => $file) {
|
||||
include $filepath;
|
||||
if (isset($mini)) {
|
||||
$minis[$mini->name] = $mini;
|
||||
}
|
||||
}
|
||||
return $minis;
|
||||
}
|
Reference in New Issue
Block a user