1 |
e5e66f93
|
Assos Assos
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
* @file
|
4 |
|
|
* Panelizer tests.
|
5 |
|
|
*/
|
6 |
|
|
|
7 |
|
|
/**
|
8 |
|
|
* Verifies Panelizer configuration options for user entities.
|
9 |
|
|
*/
|
10 |
|
|
class PanelizerUserTest extends PanelizerTestHelper {
|
11 |
|
|
|
12 |
|
|
protected $admin_user;
|
13 |
|
|
|
14 |
|
|
/**
|
15 |
|
|
* {@inheritdoc}
|
16 |
|
|
*/
|
17 |
|
|
public static function getInfo() {
|
18 |
|
|
return array(
|
19 |
|
|
'name' => 'Panelizer user workflow (excluding IPE)',
|
20 |
|
|
'description' => 'Test the typical workflow of working with users, excluding IPE.',
|
21 |
|
|
'group' => 'Panelizer',
|
22 |
|
|
);
|
23 |
|
|
}
|
24 |
|
|
|
25 |
|
|
/**
|
26 |
|
|
* {@inheritdoc}
|
27 |
|
|
*/
|
28 |
|
|
function setUp(array $modules = array()) {
|
29 |
|
|
parent::setUp();
|
30 |
|
|
|
31 |
|
|
// Create a user with the necessary permissions.
|
32 |
|
|
$perms = array(
|
33 |
|
|
// Master permission for all Panelizer operations.
|
34 |
|
|
'administer panelizer',
|
35 |
|
|
|
36 |
|
|
// Full control over this entity.
|
37 |
|
|
'administer users',
|
38 |
|
|
);
|
39 |
|
|
$this->admin_user = $this->drupalCreateUser($perms);
|
40 |
|
|
$this->drupalLogin($this->admin_user);
|
41 |
|
|
}
|
42 |
|
|
|
43 |
|
|
/**
|
44 |
|
|
* Test the user configuration functionality.
|
45 |
|
|
*/
|
46 |
|
|
function testUserConfiguration() {
|
47 |
|
|
// Load the users settings page.
|
48 |
|
|
$this->drupalGet('admin/config/people/accounts');
|
49 |
|
|
$this->assertResponse(200);
|
50 |
|
|
|
51 |
|
|
// Confirm that the appropriate fields are present.
|
52 |
|
|
$this->assertFieldByName('panelizer[status]');
|
53 |
|
|
$this->assertFieldByName('panelizer[help]');
|
54 |
|
|
foreach (array('page_manager', 'default') as $view_mode) {
|
55 |
|
|
$this->assertFieldByName('panelizer[view modes][' . $view_mode . '][status]');
|
56 |
|
|
$this->assertFieldByName('panelizer[view modes][' . $view_mode . '][default]');
|
57 |
|
|
$this->assertFieldByName('panelizer[view modes][' . $view_mode . '][choice]');
|
58 |
|
|
}
|
59 |
|
|
|
60 |
|
|
// Submit the form to panelize the user entity.
|
61 |
|
|
$edit = array(
|
62 |
|
|
// Enable Panelzier.
|
63 |
|
|
'panelizer[status]' => TRUE,
|
64 |
|
|
'panelizer[view modes][page_manager][status]' => TRUE,
|
65 |
|
|
'panelizer[view modes][page_manager][default]' => TRUE,
|
66 |
|
|
);
|
67 |
|
|
$this->drupalPost(NULL, $edit, t('Save configuration'));
|
68 |
|
|
$this->assertResponse(200);
|
69 |
|
|
|
70 |
|
|
// Confirm the settings saved correctly.
|
71 |
|
|
$pm_links = array(
|
72 |
|
|
'!pm' => l('Page Manager', 'admin/structure/pages'),
|
73 |
|
|
'!panels' => l('Panels', 'admin/structure/panels'),
|
74 |
|
|
'!task_name' => 'user_view',
|
75 |
|
|
'!entity_type' => 'user',
|
76 |
|
|
);
|
77 |
|
|
$this->assertText(strip_tags(t('Note: "!task_name" display must be enabled in !pm in order for the !entity_type full page display ("Full page override") to work correctly.', $pm_links)));
|
78 |
|
|
$this->assertText(t('The configuration options have been saved.'));
|
79 |
|
|
|
80 |
|
|
// Verify the user can be panelized.
|
81 |
|
|
$this->drupalGet('user/' . $this->admin_user->uid);
|
82 |
|
|
$this->assertResponse(200);
|
83 |
|
|
$this->assertLink('Customize display', 0, 'The "Customize display" link appears on the page');
|
84 |
|
|
$this->assertLinkByHref('user/' . $this->admin_user->uid . '/panelizer', 0, 'A link to customize the user page display appears on the page');
|
85 |
|
|
|
86 |
|
|
// Check that the view mode has not been panelized yet.
|
87 |
|
|
$elements = $this->xpath('//div[contains(@class,:class)]', array(':class' => 'panelizer-view-mode'));
|
88 |
|
|
$this->assertEqual(count($elements), 0, 'The user object display is not panelized yet.');
|
89 |
|
|
$this->assertText(t('Member for'));
|
90 |
|
|
|
91 |
|
|
// Enable the Page Manager handler for the user_view display.
|
92 |
|
|
variable_set('page_manager_user_view_disabled', FALSE);
|
93 |
|
|
|
94 |
|
|
drupal_flush_all_caches();
|
95 |
|
|
|
96 |
|
|
// Check that the view mode has now been panelized.
|
97 |
|
|
$this->drupalGet('user/' . $this->admin_user->uid);
|
98 |
|
|
$this->assertResponse(200);
|
99 |
|
|
$this->assertLink('Customize display', 0, 'The "Customize display" link appears on the page');
|
100 |
|
|
$this->assertLinkByHref('user/' . $this->admin_user->uid . '/panelizer', 0, 'A link to customize the user page display appears on the page');
|
101 |
|
|
$this->assertNoText(t('Member for'));
|
102 |
|
|
// This won't be available because there's no default display for the user
|
103 |
|
|
// entity.
|
104 |
|
|
// $elements = $this->xpath('//div[contains(@class,:class)]', array(':class' => 'panelizer-view-mode'));
|
105 |
|
|
// $this->assertEqual(count($elements), 1, 'The user object display is now panelized.');
|
106 |
|
|
}
|
107 |
|
|
|
108 |
|
|
/**
|
109 |
|
|
* Confirm that individual objects can be panelized.
|
110 |
|
|
*/
|
111 |
|
|
function testUserPanelizeIt() {
|
112 |
|
|
$this->togglePanelizer('user', 'user', 'default', 1, 0, 0);
|
113 |
|
|
|
114 |
|
|
// Check that the view mode can be panelized.
|
115 |
|
|
$this->drupalGet('user/' . $this->admin_user->uid . '/panelizer');
|
116 |
|
|
$this->assertResponse(200);
|
117 |
|
|
$this->assertText('Default');
|
118 |
|
|
$this->assertLink('panelize', 0, 'The panelize link for the default view mode appears on the page');
|
119 |
|
|
$this->assertLinkByHref('user/' . $this->admin_user->uid . '/panelizer/default', 0, 'A link to panelize the default view mode appears on the page');
|
120 |
|
|
|
121 |
|
|
// Verify that the view mode is not currently panelized.
|
122 |
|
|
$this->drupalGet('user/' . $this->admin_user->uid . '/panelizer/default');
|
123 |
|
|
$this->assertResponse(200);
|
124 |
|
|
$this->assertRaw(t('This %entity is not currently panelized.', array('%entity' => 'User')));
|
125 |
|
|
|
126 |
|
|
// Panelize the view mode.
|
127 |
|
|
$this->drupalPost(NULL, array(), t('Panelize it!'));
|
128 |
|
|
$this->assertResponse(200);
|
129 |
|
|
|
130 |
|
|
// Check that the view mode has been panelized.
|
131 |
|
|
$this->drupalGet('user/' . $this->admin_user->uid);
|
132 |
|
|
$this->assertResponse(200);
|
133 |
|
|
$this->assertNoText(t('Member for'), 'The user is panelized');
|
134 |
|
|
|
135 |
|
|
// This won't be available because there's no default display for the user
|
136 |
|
|
// entity.
|
137 |
|
|
// $elements = $this->xpath('//div[contains(@class,:class)]', array(':class' => 'panelizer-view-mode'));
|
138 |
|
|
// $this->assertEqual(count($elements), 1, 'The user is panelized.');
|
139 |
|
|
}
|
140 |
|
|
|
141 |
|
|
/**
|
142 |
|
|
*
|
143 |
|
|
*/
|
144 |
|
|
// function testUserPanelsDefault() {
|
145 |
|
|
// $this->enableVocabPanelizer(1, 1);
|
146 |
|
|
// $term = $this->createTestTerm();
|
147 |
|
|
//
|
148 |
|
|
// // Verify that the view mode has a default panel.
|
149 |
|
|
// $this->drupalGet('admin/structure/taxonomy/panelizer_vocabulary/panelizer');
|
150 |
|
|
// $this->assertResponse(200);
|
151 |
|
|
// $this->assertLinkByHref('admin/structure/taxonomy/panelizer_vocabulary/panelizer/default', 0, 'User is able to provide default panel for default');
|
152 |
|
|
//
|
153 |
|
|
// $edit = array();
|
154 |
|
|
// $edit['layout'] = 'twocol_bricks';
|
155 |
|
|
// $this->drupalPost('admin/structure/taxonomy/panelizer_vocabulary/panelizer/default/layout', $edit, t('Save'));
|
156 |
|
|
//
|
157 |
|
|
// // Check that the layout has been set.
|
158 |
|
|
// $this->drupalGet('taxonomy/term/' . $term->tid);
|
159 |
|
|
// $this->assertResponse(200);
|
160 |
|
|
// $elements = $this->xpath('//div[contains(@class,:class)]', array(':class' => 'panel-2col-bricks'));
|
161 |
|
|
// $this->assertEqual(count($elements), 1, 'The default term layout has been set.');
|
162 |
|
|
// }
|
163 |
|
|
|
164 |
|
|
} |