1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Base functions and tests for Display Suite.
|
6
|
*/
|
7
|
|
8
|
class dsExportablesTests extends dsBaseTest {
|
9
|
|
10
|
/**
|
11
|
* Implements getInfo().
|
12
|
*/
|
13
|
public static function getInfo() {
|
14
|
return array(
|
15
|
'name' => t('Exportables'),
|
16
|
'description' => t('Tests for exportables in Display Suite.'),
|
17
|
'group' => t('Display Suite'),
|
18
|
);
|
19
|
}
|
20
|
|
21
|
/**
|
22
|
* Enables the exportables module.
|
23
|
*/
|
24
|
function dsExportablesSetup() {
|
25
|
module_enable(array('ds_exportables_test'));
|
26
|
drupal_flush_all_caches();
|
27
|
}
|
28
|
|
29
|
// Test view modes.
|
30
|
function testDSExportablesViewmodes() {
|
31
|
$this->dsExportablesSetup();
|
32
|
|
33
|
// Find a default view mode on admin screen.
|
34
|
$this->drupalGet('admin/structure/ds/view_modes');
|
35
|
$this->assertText('Test exportables', t('Exportables view mode found on admin screen.'));
|
36
|
|
37
|
// Find default view mode on layout screen.
|
38
|
$this->drupalGet('admin/structure/types/manage/article/display');
|
39
|
$this->assertText('Test exportables', t('Exportables view mode found on display screen.'));
|
40
|
|
41
|
// Override default view mode.
|
42
|
$edit = array(
|
43
|
'name' => 'Testing 2',
|
44
|
);
|
45
|
$this->drupalPost('admin/structure/ds/view_modes/manage/test_exportables', $edit, t('Save'));
|
46
|
$this->assertText(t('The view mode Testing 2 has been saved'), t('Exportables label updated'));
|
47
|
$this->assertText(t('Revert'), t('Revert button found.'));
|
48
|
|
49
|
// Find default view mode on layout screen.
|
50
|
$this->drupalGet('admin/structure/types/manage/article/display');
|
51
|
$this->assertText('Testing 2', t('Updated exportables view mode found on display screen.'));
|
52
|
|
53
|
// Revert the view mode.
|
54
|
$this->drupalPost('admin/structure/ds/view_modes/revert/test_exportables', array(), t('Revert'));
|
55
|
$this->assertText(t('The view mode Testing 2 has been reverted'), t('Testing view mode reverted'));
|
56
|
$this->assertText('Test exportables', t('Exportables view mode found on admin screen.'));
|
57
|
|
58
|
// Assert the view mode is gone at the manage display screen.
|
59
|
$this->drupalGet('admin/structure/types/manage/article/display');
|
60
|
$this->assertNoText('Testing 2', t('Overrided exportables view mode not found on display screen.'));
|
61
|
$this->assertText('Test exportables', t('Default exportables view mode found on display screen.'));
|
62
|
}
|
63
|
|
64
|
// Test layout and field settings configuration.
|
65
|
function testDSExportablesLayoutFieldsettings() {
|
66
|
$this->dsExportablesSetup();
|
67
|
|
68
|
$this->drupalGet('admin/structure/types/manage/article/display');
|
69
|
$this->assertNoText(t('This layout is overridden. Click to revert to default settings.'));
|
70
|
|
71
|
$settings = array(
|
72
|
'type' => 'article',
|
73
|
'title' => 'Exportable'
|
74
|
);
|
75
|
$node = $this->drupalCreateNode($settings);
|
76
|
$this->drupalGet('node/' . $node->nid);
|
77
|
$this->assertRaw('group-left', 'Left region found');
|
78
|
$this->assertRaw('group-right', 'Right region found');
|
79
|
$this->assertNoRaw('group-header', 'No header region found');
|
80
|
$this->assertNoRaw('group-footer', 'No footer region found');
|
81
|
$this->assertRaw('<h3><a href="'. url('node/1') . '" class="active">Exportable</a></h3>', t('Default title with h3 found'));
|
82
|
$this->assertRaw('<a href="' . url('node/1') . '" class="active">Read more</a>', t('Default read more found'));
|
83
|
|
84
|
// Override default layout.
|
85
|
$layout = array(
|
86
|
'additional_settings[layout]' => 'ds_2col_stacked',
|
87
|
);
|
88
|
|
89
|
$assert = array(
|
90
|
'regions' => array(
|
91
|
'header' => '<td colspan="8">' . t('Header') . '</td>',
|
92
|
'left' => '<td colspan="8">' . t('Left') . '</td>',
|
93
|
'right' => '<td colspan="8">' . t('Right') . '</td>',
|
94
|
'footer' => '<td colspan="8">' . t('Footer') . '</td>',
|
95
|
),
|
96
|
);
|
97
|
|
98
|
$fields = array(
|
99
|
'fields[post_date][region]' => 'header',
|
100
|
'fields[author][region]' => 'left',
|
101
|
'fields[links][region]' => 'left',
|
102
|
'fields[body][region]' => 'right',
|
103
|
'fields[comments][region]' => 'footer',
|
104
|
);
|
105
|
|
106
|
$this->dsSelectLayout($layout, $assert);
|
107
|
$this->assertText(t('This layout is overridden. Click to revert to default settings.'));
|
108
|
$this->dsConfigureUI($fields);
|
109
|
|
110
|
$this->drupalGet('node/' . $node->nid);
|
111
|
$this->assertRaw('group-left', 'Left region found');
|
112
|
$this->assertRaw('group-right', 'Left region found');
|
113
|
$this->assertRaw('group-header', 'Left region found');
|
114
|
$this->assertRaw('group-footer', 'Left region found');
|
115
|
|
116
|
// Revert.
|
117
|
$edit = array();
|
118
|
$this->drupalPost('admin/structure/ds/revert-layout/node|article|default', $edit, t('Revert'), array('query' => array('destination' => 'admin/structure/types/manage/article/display')));
|
119
|
$this->drupalGet('node/' . $node->nid);
|
120
|
$this->assertRaw('group-left', 'Left region found');
|
121
|
$this->assertRaw('group-right', 'Left region found');
|
122
|
$this->assertNoRaw('group-header', 'Left region found');
|
123
|
$this->assertNoRaw('group-footer', 'Left region found');
|
124
|
$this->assertRaw('<h3><a href="'. url('node/1') . '" class="active">Exportable</a></h3>', t('Default title with h3 found'));
|
125
|
$this->assertRaw('<a href="' . url('node/1') . '" class="active">Read more</a>', t('Default read more found'));
|
126
|
}
|
127
|
|
128
|
// Test custom field exportables.
|
129
|
function testDSExportablesCustomFields() {
|
130
|
$this->dsExportablesSetup();
|
131
|
|
132
|
// Look for default custom field.
|
133
|
$this->drupalGet('admin/structure/ds/fields');
|
134
|
$this->assertText('Exportable field');
|
135
|
$this->drupalGet('admin/structure/types/manage/article/display');
|
136
|
$this->assertText('Exportable field');
|
137
|
|
138
|
// Override custom field.
|
139
|
// Update testing label
|
140
|
$edit = array(
|
141
|
'name' => 'Overridden field',
|
142
|
);
|
143
|
$this->drupalPost('admin/structure/ds/fields/manage_custom/ds_exportable_field', $edit, t('Save'));
|
144
|
$this->assertText(t('The field Overridden field has been saved'), t('Default exportable field label updated'));
|
145
|
$this->assertText('Overridden field');
|
146
|
$this->assertNoText('Exportable field');
|
147
|
$this->drupalGet('admin/structure/types/manage/article/display');
|
148
|
$this->assertText('Overridden field');
|
149
|
$this->assertNoText('Exportable field');
|
150
|
|
151
|
// Revert.
|
152
|
$edit = array();
|
153
|
$this->drupalPost('admin/structure/ds/fields/revert/ds_exportable_field', $edit, t('Revert'));
|
154
|
$this->assertText('The field Overridden field has been reverted', t('Field reverted'));
|
155
|
$this->assertText('Exportable field');
|
156
|
$this->drupalGet('admin/structure/types/manage/article/display');
|
157
|
$this->assertNoText('Overridden field');
|
158
|
$this->assertText('Exportable field');
|
159
|
}
|
160
|
}
|