1 |
2545992a
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Test the exportables functionality for Panelizer.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
class PanelizerExportablesTest extends PanelizerTestHelper {
|
9 |
|
|
|
10 |
|
|
/**
|
11 |
|
|
* {@inheritdoc}
|
12 |
|
|
*/
|
13 |
|
|
public static function getInfo() {
|
14 |
|
|
return array(
|
15 |
|
|
'name' => 'Panelizer exportables',
|
16 |
|
|
'description' => 'Test how exported configurations work.',
|
17 |
|
|
'group' => 'Panelizer',
|
18 |
|
|
);
|
19 |
|
|
}
|
20 |
|
|
|
21 |
|
|
/**
|
22 |
|
|
* {@inheritdoc}
|
23 |
|
|
*/
|
24 |
|
|
function setUp(array $modules = array()) {
|
25 |
|
|
// Need this extra module for the default it exports.
|
26 |
|
|
$modules[] = 'panelizer_test_exportables';
|
27 |
|
|
|
28 |
|
|
parent::setUp($modules);
|
29 |
|
|
|
30 |
|
|
// Enable Panelizer for the 'page' content type.
|
31 |
|
|
$this->togglePanelizer();
|
32 |
|
|
// Enable the Panels view mode too.
|
33 |
|
|
$this->simpleEnablePage('node_view');
|
34 |
|
|
|
35 |
|
|
// Reset the static variable used to identify permissions, otherwise the
|
36 |
|
|
// permissions check in drupalCreateUser will fail because of the new perms
|
37 |
|
|
// added for the newly Panelizered entity display.
|
38 |
|
|
$this->checkPermissions(array(), TRUE);
|
39 |
|
|
}
|
40 |
|
|
|
41 |
|
|
/**
|
42 |
|
|
* Verify that the exported configuration can be edited.
|
43 |
|
|
*/
|
44 |
|
|
function testExportablesAreConfigurable() {
|
45 |
|
|
$perms = array(
|
46 |
|
|
// Standard node permissions.
|
47 |
|
|
'administer content types',
|
48 |
|
|
'access administration pages',
|
49 |
|
|
|
50 |
|
|
// Panelizer.
|
51 |
|
|
'administer panelizer',
|
52 |
|
|
|
53 |
|
|
// Permission to manage the 'content', i.e. the display.
|
54 |
|
|
'administer panelizer node page content',
|
55 |
|
|
);
|
56 |
|
|
$web_user = $this->drupalCreateUser($perms);
|
57 |
|
|
$this->drupalLogin($web_user);
|
58 |
|
|
|
59 |
|
|
// Load the Panelizer admin page for the 'page' content type.
|
60 |
|
|
$this->drupalGet('admin/structure/types/manage/page/panelizer/page_manager');
|
61 |
|
|
$this->assertResponse(200);
|
62 |
|
|
|
63 |
|
|
// The two defaults that were exported.
|
64 |
|
|
$defaults = array(
|
65 |
|
|
'node:page:with_storage' => 'Test (with Storage API)',
|
66 |
|
|
'node:page:without_storage' => 'Test (without Storage API)',
|
67 |
|
|
);
|
68 |
|
|
|
69 |
|
|
// Confirm the two exported displays are listed.
|
70 |
|
|
foreach ($defaults as $default => $label) {
|
71 |
|
|
$this->assertText($default);
|
72 |
|
|
}
|
73 |
|
|
|
74 |
|
|
// Try loading the exported displays' configuration pages.
|
75 |
|
|
foreach ($defaults as $default => $label) {
|
76 |
|
|
// $default = urlencode($default);
|
77 |
|
|
$this->drupalGet('admin/structure/types/manage/page/panelizer/page_manager/' . $default . '/settings');
|
78 |
|
|
$this->assertResponse(200);
|
79 |
|
|
$this->assertFieldByName('title', $label);
|
80 |
|
|
$this->assertFieldByName('css_class', str_replace(':', '-', $default));
|
81 |
|
|
$this->drupalGet('admin/structure/types/manage/page/panelizer/page_manager/' . $default . '/context');
|
82 |
|
|
$this->assertResponse(200);
|
83 |
|
|
$this->assertText(t('Built in context'));
|
84 |
|
|
$this->drupalGet('admin/structure/types/manage/page/panelizer/page_manager/' . $default . '/access');
|
85 |
|
|
$this->assertResponse(200);
|
86 |
|
|
$this->assertText(t('No criteria selected, this test will pass.'));
|
87 |
|
|
$this->drupalGet('admin/structure/types/manage/page/panelizer/page_manager/' . $default . '/layout');
|
88 |
|
|
$this->assertResponse(200);
|
89 |
|
|
$this->assertFieldByName('categories');
|
90 |
|
|
$this->drupalGet('admin/structure/types/manage/page/panelizer/page_manager/' . $default . '/content');
|
91 |
|
|
$this->assertResponse(200);
|
92 |
|
|
}
|
93 |
|
|
}
|
94 |
|
|
|
95 |
|
|
/**
|
96 |
|
|
* Verify that the exported configuration can be edited when applied to an
|
97 |
|
|
* individual entity.
|
98 |
|
|
*/
|
99 |
|
|
function testExportablesChangeablePreEntity() {
|
100 |
|
|
$perms = array(
|
101 |
|
|
// Standard node permissions.
|
102 |
|
|
'create page content',
|
103 |
|
|
'edit own page content',
|
104 |
|
|
|
105 |
|
|
// Allow access to the 'panelizer' tab.
|
106 |
|
|
'administer panelizer node page overview',
|
107 |
|
|
// Permission to manage the 'content', i.e. the display.
|
108 |
|
|
'administer panelizer node page content',
|
109 |
|
|
// Allow choosing the display that is used.
|
110 |
|
|
'administer panelizer node page choice',
|
111 |
|
|
);
|
112 |
|
|
$web_user = $this->drupalCreateUser($perms);
|
113 |
|
|
$this->drupalLogin($web_user);
|
114 |
|
|
|
115 |
|
|
// Create a node.
|
116 |
|
|
$edit = array(
|
117 |
|
|
'panelizer[page_manager][name]' => 'node:page:without_storage',
|
118 |
|
|
);
|
119 |
|
|
$node = $this->createNode($edit);
|
120 |
|
|
$this->assertNotEqual($node->nid, 0);
|
121 |
|
|
|
122 |
|
|
// Load the Panelizer main page.
|
123 |
|
|
$this->drupalGet('node/' . $node->nid . '/panelizer');
|
124 |
|
|
$this->assertResponse(200);
|
125 |
|
|
|
126 |
|
|
// Confirm there's a link to the 'content' page, and load it.
|
127 |
|
|
$path = 'node/' . $node->nid . '/panelizer/page_manager/content';
|
128 |
|
|
$this->assertLinkByHref(url($path));
|
129 |
|
|
$this->drupalGet($path);
|
130 |
|
|
$this->assertResponse(200);
|
131 |
|
|
|
132 |
|
|
// Confirm the 'Add content' link is on the page.
|
133 |
|
|
$this->assertLink(t('Add content'));
|
134 |
|
|
$ajax_path = 'panels/ajax/editor/select-content/panelizer:node:' . $node->nid . ':page_manager:' . $node->vid . '/center';
|
135 |
|
|
// Need to pass the path through url() to get the correct syntax for the
|
136 |
|
|
// actual link.
|
137 |
|
|
$this->assertLinkByHref(url($ajax_path));
|
138 |
|
|
|
139 |
|
|
// Load the AJAX path to see what it contains.
|
140 |
|
|
$json = $this->drupalGetAJAX($ajax_path);
|
141 |
|
|
$this->assertResponse(200);
|
142 |
|
|
|
143 |
|
|
// Examine the JSON response from the AJAX API.
|
144 |
|
|
$this->verbose('<pre>' . print_r($json, TRUE) . '</pre>');
|
145 |
|
|
// $this->assertEqual(count($json), 2);
|
146 |
|
|
$this->assertTrue(isset($json[0]['command']));
|
147 |
|
|
$this->assertEqual($json[0]['command'], 'settings');
|
148 |
|
|
$this->assertTrue(isset($json[0]['settings']));
|
149 |
|
|
$this->assertTrue(isset($json[0]['merge']));
|
150 |
|
|
$this->assertEqual($json[0]['merge'], 'TRUE');
|
151 |
|
|
$this->assertTrue(isset($json[1]['command']));
|
152 |
|
|
|
153 |
|
|
// This is what should happen.
|
154 |
|
|
$this->assertEqual($json[1]['command'], 'modal_display');
|
155 |
|
|
$this->assertTrue(isset($json[1]['title']));
|
156 |
|
|
if (isset($json[1]['title'])) {
|
157 |
|
|
$this->assertEqual($json[1]['title'], t('Add content to Center'));
|
158 |
|
|
}
|
159 |
|
|
$this->assertTrue(isset($json[1]['output']));
|
160 |
|
|
|
161 |
|
|
// This is what should not happen.
|
162 |
|
|
$this->assertNotEqual($json[1]['command'], 'alert');
|
163 |
|
|
$this->assertFalse(isset($json[1]['text']));
|
164 |
|
|
if (isset($json[1]['text'])) {
|
165 |
|
|
$this->assertNotEqual($json[1]['text'], t('You are not authorized to access this page.'), 'Access Denied error in the AJAX response.');
|
166 |
|
|
}
|
167 |
|
|
}
|
168 |
|
|
|
169 |
|
|
} |