1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Entities tests
|
6
|
*/
|
7
|
|
8
|
class dsViewsTests extends dsBaseTest {
|
9
|
|
10
|
/**
|
11
|
* Implements getInfo().
|
12
|
*/
|
13
|
public static function getInfo() {
|
14
|
return array(
|
15
|
'name' => t('Views'),
|
16
|
'description' => t('Tests for Display Suite Views integration.'),
|
17
|
'group' => t('Display Suite'),
|
18
|
);
|
19
|
}
|
20
|
|
21
|
/**
|
22
|
* Test views integration.
|
23
|
*/
|
24
|
function testDSViews() {
|
25
|
|
26
|
$edit_tag_1 = array(
|
27
|
'field_tags[und]' => 'Tag 1',
|
28
|
);
|
29
|
$edit_tag_2 = array(
|
30
|
'field_tags[und]' => 'Tag 2',
|
31
|
);
|
32
|
|
33
|
// Create 3 nodes.
|
34
|
$settings_1 = array(
|
35
|
'type' => 'article',
|
36
|
'title' => 'Article 1',
|
37
|
'created' => REQUEST_TIME,
|
38
|
);
|
39
|
$node_1 = $this->drupalCreateNode($settings_1);
|
40
|
$this->drupalPost('node/' . $node_1->nid . '/edit', $edit_tag_1, t('Save'));
|
41
|
$settings_2 = array(
|
42
|
'type' => 'article',
|
43
|
'title' => 'Article 2',
|
44
|
'created' => REQUEST_TIME + 3600,
|
45
|
);
|
46
|
$node_2 = $this->drupalCreateNode($settings_2);
|
47
|
$this->drupalPost('node/' . $node_2->nid . '/edit', $edit_tag_1, t('Save'));
|
48
|
$settings_3 = array(
|
49
|
'type' => 'article',
|
50
|
'title' => 'Article 3',
|
51
|
'created' => REQUEST_TIME + 7200,
|
52
|
);
|
53
|
$node_3 = $this->drupalCreateNode($settings_3);
|
54
|
$this->drupalPost('node/' . $node_3->nid . '/edit', $edit_tag_2, t('Save'));
|
55
|
|
56
|
// Configure teaser and full layout.
|
57
|
$layout = array(
|
58
|
'additional_settings[layout]' => 'ds_2col',
|
59
|
);
|
60
|
$fields = array(
|
61
|
'fields[title][region]' => 'left',
|
62
|
'fields[body][region]' => 'right',
|
63
|
);
|
64
|
$assert = array(
|
65
|
'regions' => array(
|
66
|
'left' => '<td colspan="8">' . t('Left') . '</td>',
|
67
|
'right' => '<td colspan="8">' . t('Right') . '</td>',
|
68
|
),
|
69
|
);
|
70
|
$this->dsSelectLayout($layout, $assert, 'admin/structure/types/manage/article/display/teaser');
|
71
|
$this->dsConfigureUI($fields, 'admin/structure/types/manage/article/display/teaser');
|
72
|
$layout = array(
|
73
|
'additional_settings[layout]' => 'ds_4col',
|
74
|
);
|
75
|
$fields = array(
|
76
|
'fields[post_date][region]' => 'first',
|
77
|
'fields[body][region]' => 'second',
|
78
|
'fields[author][region]' => 'third',
|
79
|
'fields[node_link][region]' => 'fourth',
|
80
|
);
|
81
|
$assert = array(
|
82
|
'regions' => array(
|
83
|
'first' => '<td colspan="8">' . t('First') . '</td>',
|
84
|
'second' => '<td colspan="8">' . t('Second') . '</td>',
|
85
|
'third' => '<td colspan="8">' . t('Third') . '</td>',
|
86
|
'fourth' => '<td colspan="8">' . t('Fourth') . '</td>',
|
87
|
),
|
88
|
);
|
89
|
$this->dsSelectLayout($layout, $assert);
|
90
|
$this->dsConfigureUI($fields);
|
91
|
|
92
|
// Get default teaser view.
|
93
|
$this->drupalGet('ds-testing');
|
94
|
foreach (array('group-left', 'group-right') as $region) {
|
95
|
$this->assertRaw($region, t('Region !region found', array('!region' => $region)));
|
96
|
}
|
97
|
$this->assertRaw('Article 1');
|
98
|
$this->assertRaw('Article 2');
|
99
|
$this->assertRaw('Article 3');
|
100
|
|
101
|
// Get alternating view.
|
102
|
$this->drupalGet('ds-testing-2');
|
103
|
foreach (array('group-left', 'group-right', 'first', 'second', 'third', 'fourth') as $region) {
|
104
|
$this->assertRaw($region, t('Region !region found', array('!region' => $region)));
|
105
|
}
|
106
|
$this->assertNoRaw('Article 1');
|
107
|
$this->assertRaw('Article 2');
|
108
|
$this->assertRaw('Article 3');
|
109
|
|
110
|
// Get grouping view (without changing header function).
|
111
|
$this->drupalGet('ds-testing-3');
|
112
|
foreach (array('group-left', 'group-right') as $region) {
|
113
|
$this->assertRaw($region, t('Region !region found', array('!region' => $region)));
|
114
|
}
|
115
|
$this->assertRaw('Article 1');
|
116
|
$this->assertRaw('Article 2');
|
117
|
$this->assertRaw('Article 3');
|
118
|
$this->assertRaw('<h2 class="grouping-title">1</h2>');
|
119
|
$this->assertRaw('<h2 class="grouping-title">2</h2>');
|
120
|
|
121
|
// Get grouping view (with changing header function).
|
122
|
$this->drupalGet('ds-testing-4');
|
123
|
foreach (array('group-left', 'group-right') as $region) {
|
124
|
$this->assertRaw($region, t('Region !region found', array('!region' => $region)));
|
125
|
}
|
126
|
$this->assertRaw('Article 1');
|
127
|
$this->assertRaw('Article 2');
|
128
|
$this->assertRaw('Article 3');
|
129
|
$this->assertRaw('<h2 class="grouping-title">Tag 1</h2>');
|
130
|
$this->assertRaw('<h2 class="grouping-title">Tag 2</h2>');
|
131
|
|
132
|
// Get advanced function view.
|
133
|
$this->drupalGet('ds-testing-5');
|
134
|
$this->assertRaw('Advanced display for id 1');
|
135
|
$this->assertRaw('Advanced display for id 2');
|
136
|
$this->assertRaw('Advanced display for id 3');
|
137
|
|
138
|
// Test views templates overrides.
|
139
|
$this->drupalGet('admin/structure/ds/vd/manage/ds_testing-page_5/display');
|
140
|
$this->assertText('No view found to layout.');
|
141
|
$edit = array(
|
142
|
'vd' => 'ds_testing-page_5',
|
143
|
);
|
144
|
$this->drupalPost('admin/structure/ds/vd', $edit, t('Add'));
|
145
|
$this->dsSelectLayout(array(), array(), 'admin/structure/ds/vd/manage/ds_testing-page_5/display');
|
146
|
$edit = array(
|
147
|
'fields[pager][region]' => 'header',
|
148
|
'fields[footer][region]' => 'header',
|
149
|
'fields[rows][region]' => 'left',
|
150
|
'fields[exposed][region]' => 'right',
|
151
|
'fields[header][region]' => 'footer',
|
152
|
);
|
153
|
$this->dsConfigureUI($edit, 'admin/structure/ds/vd/manage/ds_testing-page_5/display');
|
154
|
|
155
|
// Test on the views page itself.
|
156
|
$this->drupalGet('ds-testing-6');
|
157
|
$this->assertRaw('<div class="group-header">
|
158
|
<p>Footer text</p>
|
159
|
</div>');
|
160
|
$this->assertRaw('<div class="group-left">
|
161
|
<div class="views-row views-row-1 views-row-odd views-row-first">');
|
162
|
$this->assertRaw('<div class="group-right">
|
163
|
<form action="' . url('ds-testing-6') . '"');
|
164
|
$this->assertRaw('<div class="group-footer">
|
165
|
<p>Header text</p>');
|
166
|
}
|
167
|
}
|