1 |
e5e66f93
|
Assos Assos
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
* @file
|
4 |
|
|
* Test the Pathauto integration for Panelizer.
|
5 |
|
|
*/
|
6 |
|
|
|
7 |
|
|
/**
|
8 |
|
|
*
|
9 |
|
|
*/
|
10 |
|
|
class PanelizerWithPathautoTest extends PanelizerTestHelper {
|
11 |
|
|
|
12 |
|
|
/**
|
13 |
|
|
* {@inheritdoc}
|
14 |
|
|
*/
|
15 |
|
|
public static function getInfo() {
|
16 |
|
|
return array(
|
17 |
|
|
'name' => 'Panelizer w Pathauto',
|
18 |
|
|
'description' => 'Test Pathauto integration.',
|
19 |
|
|
'group' => 'Panelizer',
|
20 |
|
|
);
|
21 |
|
|
}
|
22 |
|
|
|
23 |
|
|
/**
|
24 |
|
|
* {@inheritdoc}
|
25 |
|
|
*/
|
26 |
|
|
function setUp(array $modules = array()) {
|
27 |
|
|
$modules[] = 'pathauto';
|
28 |
|
|
parent::setUp($modules);
|
29 |
|
|
|
30 |
|
|
$perms = array(
|
31 |
|
|
// Standard node permissions.
|
32 |
|
|
'create page content',
|
33 |
|
|
'administer content types',
|
34 |
|
|
'administer nodes',
|
35 |
|
|
'bypass node access',
|
36 |
|
|
|
37 |
|
|
// Panelizer.
|
38 |
|
|
'administer panelizer',
|
39 |
|
|
|
40 |
|
|
// Pathauto.
|
41 |
|
|
'create url aliases',
|
42 |
|
|
);
|
43 |
|
|
$web_user = $this->drupalCreateUser($perms);
|
44 |
|
|
$this->drupalLogin($web_user);
|
45 |
|
|
}
|
46 |
|
|
|
47 |
|
|
/**
|
48 |
|
|
* Confirm that saving the Panelizer page doesn't remove the Pathauto alias.
|
49 |
|
|
*/
|
50 |
|
|
function testNodeSave() {
|
51 |
|
|
// Enable Panelizer for the 'page' content type.
|
52 |
|
|
$this->togglePanelizer();
|
53 |
|
|
// Enable the Panels view mode too.
|
54 |
|
|
$this->simpleEnablePage('node_view');
|
55 |
|
|
|
56 |
|
|
// Create a node and give it a custom alias.
|
57 |
|
|
$args = array(
|
58 |
|
|
'path[pathauto]' => FALSE,
|
59 |
|
|
'path[alias]' => 'test-page',
|
60 |
|
|
);
|
61 |
|
|
$node = $this->createNode($args);
|
62 |
|
|
|
63 |
|
|
// Confirm the node loads from the custom alias.
|
64 |
|
|
$this->drupalGet('test-page');
|
65 |
|
|
$this->assertResponse(200);
|
66 |
|
|
$this->assertText($node->title);
|
67 |
|
|
$this->assertLink('Customize display', 0, 'The customize display link appears on the page');
|
68 |
|
|
$this->assertLinkByHref('node/' . $node->nid . '/panelizer', 0, 'A link to customize the node appears on the page');
|
69 |
|
|
|
70 |
|
|
// Update its Panelizer display.
|
71 |
|
|
$this->drupalGet('node/' . $node->nid . '/panelizer/page_manager/settings');
|
72 |
|
|
$this->assertResponse(200);
|
73 |
|
|
$this->assertFieldByName('css_class');
|
74 |
|
|
$args = array(
|
75 |
|
|
'css_class' => 'panelizer-test',
|
76 |
|
|
);
|
77 |
|
|
$this->drupalPost(NULL, $args, t('Save'));
|
78 |
|
|
// Confirm the settings saved correctly.
|
79 |
|
|
$this->assertText(t('The settings have been updated.'));
|
80 |
|
|
|
81 |
|
|
// Confirm that settings have been saved for this entity.
|
82 |
|
|
$records = $this->getPanelizerEntityRecords('node', $node->nid);
|
83 |
|
|
$this->assertTrue(count($records));
|
84 |
|
|
|
85 |
|
|
// Load the page again from its system path and confirm that the display
|
86 |
|
|
// has been customized.
|
87 |
|
|
$this->drupalGet('node/' . $node->nid);
|
88 |
|
|
$elements = $this->xpath('//body[contains(@class,:class)]', array(':class' => 'panelizer-test'));
|
89 |
|
|
$this->assertEqual(count($elements), 1, 'The node is using the overridden display.');
|
90 |
|
|
|
91 |
|
|
// Confirm that the node alias still works.
|
92 |
|
|
$this->drupalGet('test-page');
|
93 |
|
|
$this->assertResponse(200);
|
94 |
|
|
$this->assertText($node->title);
|
95 |
|
|
$this->assertLink('Customize display', 0, 'The customize display link appears on the page');
|
96 |
|
|
$this->assertLinkByHref('node/' . $node->nid . '/panelizer', 0, 'A link to customize the node appears on the page');
|
97 |
|
|
$elements = $this->xpath('//body[contains(@class,:class)]', array(':class' => 'panelizer-test'));
|
98 |
|
|
$this->assertEqual(count($elements), 1, 'The node is using the overridden display.');
|
99 |
|
|
}
|
100 |
|
|
|
101 |
|
|
} |