Projet

Général

Profil

Paste
Télécharger (11,3 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / panelizer / tests / panelizer.with_panels_ipe.test @ 136a805a

1
<?php
2
/**
3
 * @file
4
 * Tests for Panels IPE.
5
 */
6

    
7
class PanelizerWithPanelsIPE extends PanelizerTestHelper {
8

    
9
  /**
10
   * {@inheritdoc}
11
   */
12
  public static function getInfo() {
13
    return array(
14
      'name' => 'Panelizer IPE',
15
      'description' => 'Tests for IPE.',
16
      'group' => 'Panelizer',
17
    );
18
  }
19

    
20
  /**
21
   * {@inheritdoc}
22
   */
23
  function setUp(array $modules = array()) {
24
    $modules[] = 'panels_ipe';
25
    parent::setUp($modules);
26

    
27
    // Enable Panelizer for the 'page' content type.
28
    $this->togglePanelizer();
29
    // Enable the Panels view mode too.
30
    $this->simpleEnablePage('node_view');
31

    
32
    // Reset the static variable used to identify permissions, otherwise the
33
    // permissions check in drupalCreateUser will fail because of the new perms
34
    // added for the newly Panelizered entity display.
35
    $this->checkPermissions(array(), TRUE);
36
  }
37

    
38
  /**
39
   * Test whether the IPE 'content' permissions work correctly.
40
   */
41
  // function testIpeContentAccess() {
42
  //   $perms = array(
43
  //     // Standard node permissions.
44
  //     'create page content',
45
  //     'administer content types',
46
  //     'administer nodes',
47
  //     'bypass node access',
48
  //
49
  //     'access administration pages',
50
  //
51
  //     // Panels IPE.
52
  //     'use panels in place editing',
53
  //
54
  //     // Panelizer.
55
  //     'administer panelizer',
56
  //
57
  //     // Permission to manage the 'content', i.e. the display.
58
  //     'administer panelizer node page content',
59
  //   );
60
  //   $web_user = $this->drupalCreateUser($perms);
61
  //   $this->drupalLogin($web_user);
62
  //
63
  //   // Just 'cause.
64
  //   drupal_flush_all_caches();
65
  //   // Create a test node.
66
  //   $node = $this->createNode();
67
  //
68
  //   // Enable IPE for this node.
69
  //   $this->drupalGet('node/' . $node->nid . '/panelizer/page_manager/settings');
70
  //   $this->assertResponse(200);
71
  //   $this->assertFieldByName('pipeline');
72
  //   $edit = array(
73
  //     'pipeline' => 'ipe',
74
  //   );
75
  //   $this->drupalPost(NULL, $edit, t('Save'));
76
  //   $this->assertText(t('The settings have been updated.'));
77
  //
78
  //   // Load the node view page.
79
  //   $this->drupalGet('node/' . $node->nid);
80
  //   $this->assertResponse(200);
81
  //
82
  //   // Confirm the IPE link is on the form.
83
  //   $this->assertLink(t('Customize this page'));
84
  //   $path = 'panels/ajax/ipe/save_form/panelizer%3Anode%3A' . $node->nid . '%3Apage_manager%3A' . $node->vid;
85
  //   $query_string = array('destination' => 'node/' . $node->nid);
86
  //   $this->assertLinkByHref(base_path() . $path . '?destination=' . $query_string['destination']);
87
  //
88
  //   // Load the API path when logged in. This should give an AJAX response with
89
  //   // two commands - the first should be "settings" and the second one should
90
  //   // be "initIPE".
91
  //   $json = $this->drupalGetAJAX(urldecode($path), array('query' => $query_string));
92
  //   $this->assertResponse(200);
93
  //   $this->verbose('<pre>' . print_r($json, TRUE) . '</pre>');
94
  //   // @todo What permission does this need to get a proper response?
95
  //   $this->assertEqual(count($json), 2);
96
  //   $this->assertTrue(isset($json[0]['command']));
97
  //   $this->assertEqual($json[0]['command'], 'settings');
98
  //   $this->assertTrue(isset($json[0]['settings']));
99
  //   $this->assertTrue(isset($json[0]['merge']));
100
  //   $this->assertEqual($json[0]['merge'], 'TRUE');
101
  //   $this->assertTrue(isset($json[1]['command']));
102
  //   $this->assertEqual($json[1]['command'], 'initIPE');
103
  //   $this->assertTrue(isset($json[1]['key']));
104
  //   $this->assertEqual($json[1]['key'], 'panelizer-node-' . $node->nid . '-page-manager-' . $node->vid);
105
  //   $this->assertTrue(isset($json[1]['data']));
106
  //   $this->assertTrue(isset($json[1]['lockPath']));
107
  //
108
  //   // Log out.
109
  //   $this->drupalLogout();
110
  //
111
  //   // Load the API path when logged out. This should give a 404-by-AJAX
112
  //   // response.
113
  //   $json = $this->drupalGetAJAX(urldecode($path), array('query' => $query_string));
114
  //   $this->assertResponse(200);
115
  //   $this->verbose('<pre>' . print_r($json, TRUE) . '</pre>');
116
  //   $this->assertEqual(count($json), 2);
117
  //   $this->assertTrue(isset($json[1]['command']));
118
  //   $this->assertEqual($json[1]['command'], 'alert');
119
  //   $this->assertTrue(isset($json[1]['text']));
120
  //   $this->assertEqual($json[1]['text'], t('You are not authorized to access this page.'));
121
  //   $this->assertFalse(isset($json[1]['key']));
122
  //   $this->assertFalse(isset($json[1]['data']));
123
  //   $this->assertFalse(isset($json[1]['lockPath']));
124
  // }
125
  //
126
  // /**
127
  //  * Test whether the IPE 'layout' permissions work correctly.
128
  //  */
129
  // function testIpeLayoutAccess() {
130
  //   $perms = array(
131
  //     // Standard node permissions.
132
  //     'create page content',
133
  //     'administer content types',
134
  //     'administer nodes',
135
  //     'bypass node access',
136
  //
137
  //     // Panels IPE.
138
  //     'use panels in place editing',
139
  //     // Adds the "Change layout" functionality to IPE.
140
  //     'change layouts in place editing',
141
  //
142
  //     // Panelizer.
143
  //     'administer panelizer',
144
  //
145
  //     // Permission to modify the layout.
146
  //     'administer panelizer node page layout',
147
  //   );
148
  //   $web_user = $this->drupalCreateUser($perms);
149
  //   $this->drupalLogin($web_user);
150
  //
151
  //   // Just 'cause.
152
  //   drupal_flush_all_caches();
153
  //
154
  //   // Create a test node.
155
  //   $node = $this->createNode();
156
  //
157
  //   // Enable IPE for this node.
158
  //   $this->drupalGet('node/' . $node->nid . '/panelizer/page_manager/settings');
159
  //   $this->assertResponse(200);
160
  //   $this->assertFieldByName('pipeline');
161
  //   $edit = array(
162
  //     'pipeline' => 'ipe',
163
  //   );
164
  //   $this->drupalPost(NULL, $edit, t('Save'));
165
  //   $this->assertText(t('The settings have been updated.'));
166
  //
167
  //   // Load the node view page.
168
  //   $this->drupalGet('node/' . $node->nid);
169
  //   $this->assertResponse(200);
170
  //
171
  //   // Confirm the IPE link is on the form.
172
  //   $this->assertLink(t('Change layout'));
173
  //   $path = 'panels/ajax/ipe/change_layout/panelizer%3Anode%3A' . $node->nid . '%3Apage_manager%3A' . $node->vid;
174
  //   $query_string = array('destination' => 'node/' . $node->nid);
175
  //   $this->assertLinkByHref(base_path() . $path . '?destination=' . $query_string['destination']);
176
  //
177
  //   // Load the API path when logged in. This should give an AJAX response with
178
  //   // three commands - the first should be "settings", the second one should be
179
  //   // "modal_display" and the third "IPEsetLockState".
180
  //   $json = $this->drupalGetAJAX(urldecode($path), array('query' => $query_string));
181
  //   $this->assertResponse(200);
182
  //   $this->verbose('<pre>' . print_r($json, TRUE) . '</pre>');
183
  //   // @todo What permission does this need to get a proper response?
184
  //   $this->assertEqual(count($json), 3);
185
  //   $this->assertTrue(isset($json[0]['command']));
186
  //   $this->assertEqual($json[0]['command'], 'settings');
187
  //   $this->assertTrue(isset($json[0]['settings']));
188
  //   $this->assertTrue(isset($json[0]['merge']));
189
  //   $this->assertEqual($json[0]['merge'], 'TRUE');
190
  //   $this->assertTrue(isset($json[1]['command']));
191
  //   $this->assertEqual($json[1]['command'], 'modal_display');
192
  //   $this->assertTrue(isset($json[1]['title']));
193
  //   $this->assertEqual($json[1]['title'], t('Change layout'));
194
  //   $this->assertTrue(isset($json[2]['command']));
195
  //   $this->assertEqual($json[2]['command'], 'IPEsetLockState');
196
  //   $this->assertTrue(isset($json[2]['key']));
197
  //   $this->assertEqual($json[2]['key'], 'panelizer-node-' . $node->nid . '-page-manager-' . $node->vid);
198
  //   $this->assertTrue(isset($json[2]['lockPath']));
199
  //
200
  //   // Log out.
201
  //   $this->drupalLogout();
202
  //
203
  //   // Load the API path when logged out. This should give a 404-by-AJAX
204
  //   // response.
205
  //   $json = $this->drupalGetAJAX(urldecode($path), array('query' => $query_string));
206
  //   $this->assertResponse(200);
207
  //   $this->verbose('<pre>' . print_r($json, TRUE) . '</pre>');
208
  //   $this->assertEqual(count($json), 2);
209
  //   $this->assertTrue(isset($json[1]['command']));
210
  //   $this->assertEqual($json[1]['command'], 'alert');
211
  //   $this->assertTrue(isset($json[1]['text']));
212
  //   $this->assertEqual($json[1]['text'], t('You are not authorized to access this page.'));
213
  //   $this->assertFalse(isset($json[1]['key']));
214
  //   $this->assertFalse(isset($json[1]['data']));
215
  //   $this->assertFalse(isset($json[1]['lockPath']));
216
  // }
217

    
218
  /**
219
   * Test whether the IPE 'content' permissions work correctly w entity perms.
220
   */
221
  function testIpeContentEntityAccess() {
222
    $perms = array(
223
      // Standard node permissions.
224
      'create page content',
225
      'administer content types',
226
      'administer nodes',
227
      'bypass node access',
228

    
229
      // Panels IPE.
230
      'use panels in place editing',
231

    
232
      // Panelizer.
233
      'administer panelizer',
234

    
235
      // Permission to manage the 'content', i.e. the display.
236
      'administer panelizer node page content',
237
    );
238
    $web_user = $this->drupalCreateUser($perms);
239
    $this->drupalLogin($web_user);
240

    
241
    // Just 'cause.
242
    drupal_flush_all_caches();
243
    // Create a test node.
244
    $node = $this->createNode();
245

    
246
    // Enable IPE for this node.
247
    $this->drupalGet('node/' . $node->nid . '/panelizer/page_manager/settings');
248
    $this->assertResponse(200);
249
    $this->assertFieldByName('pipeline');
250
    $edit = array(
251
      'pipeline' => 'ipe',
252
    );
253
    $this->drupalPost(NULL, $edit, t('Save'));
254
    $this->assertText(t('The settings have been updated.'));
255

    
256
    // Load the node view page.
257
    $this->drupalGet('node/' . $node->nid);
258
    $this->assertResponse(200);
259

    
260
    // Confirm the IPE link is on the form.
261
    $this->assertLink(t('Customize this page'));
262
    $path = 'panels/ajax/ipe/save_form/panelizer%3Anode%3A' . $node->nid . '%3Apage_manager%3A' . $node->vid;
263
    $query_string = array('destination' => 'node/' . $node->nid);
264
    $this->assertLinkByHref(base_path() . $path . '?destination=' . $query_string['destination']);
265

    
266
    // Log out.
267
    $this->drupalLogout();
268

    
269
    $perms = array(
270
      // Need to be able to access the node.
271
      'access content',
272

    
273
      // Panels IPE.
274
      'use panels in place editing',
275

    
276
      // Adds the "Change layout" functionality to IPE.
277
      'change layouts in place editing',
278

    
279
      // Panelizer.
280
      'administer panelizer',
281

    
282
      // Permission to manage the 'content', i.e. the display.
283
      'administer panelizer node page content',
284
      'administer panelizer node page layout',
285
    );
286
    $web_user = $this->drupalCreateUser($perms);
287
    $this->drupalLogin($web_user);
288

    
289
    // Load the node view page.
290
    $this->drupalGet('node/' . $node->nid);
291
    $this->assertResponse(200);
292

    
293
    // Confirm the IPE link is not on the form.
294
    $this->assertNoLink(t('Customize this page'));
295
    $path = 'panels/ajax/ipe/save_form/panelizer%3Anode%3A' . $node->nid . '%3Apage_manager%3A' . $node->vid;
296
    $query_string = array('destination' => 'node/' . $node->nid);
297
    $this->assertNoLinkByHref(base_path() . $path . '?destination=' . $query_string['destination']);
298

    
299
    // Confirm the IPE link is not on the form.
300
    $this->assertNoLink(t('Change layout'));
301
    $path = 'panels/ajax/ipe/change_layout/panelizer%3Anode%3A' . $node->nid . '%3Apage_manager%3A' . $node->vid;
302
    $query_string = array('destination' => 'node/' . $node->nid);
303
    $this->assertNoLinkByHref(base_path() . $path . '?destination=' . $query_string['destination']);
304
  }
305

    
306
}