1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Entities tests
|
6
|
*/
|
7
|
|
8
|
class dsNodeTests extends dsBaseTest {
|
9
|
|
10
|
/**
|
11
|
* Implements getInfo().
|
12
|
*/
|
13
|
public static function getInfo() {
|
14
|
return array(
|
15
|
'name' => t('Node display'),
|
16
|
'description' => t('Tests for display of nodes and fields.'),
|
17
|
'group' => t('Display Suite'),
|
18
|
);
|
19
|
}
|
20
|
|
21
|
/**
|
22
|
* Utility function to setup for all kinds of tests.
|
23
|
*
|
24
|
* @param $label
|
25
|
* How the body label must be set.
|
26
|
*/
|
27
|
function entitiesTestSetup($label = 'above') {
|
28
|
|
29
|
// Create a node.
|
30
|
$settings = array('type' => 'article', 'promote' => 1);
|
31
|
$node = $this->drupalCreateNode($settings);
|
32
|
|
33
|
// Create field CSS classes.
|
34
|
$edit = array('ds_classes_fields' => "test_field_class\ntest_field_class_2|Field class 2");
|
35
|
$this->drupalPost('admin/structure/ds/classes', $edit, t('Save configuration'));
|
36
|
|
37
|
// Create a token and php field.
|
38
|
$token_field = array(
|
39
|
'name' => 'Token field',
|
40
|
'field' => 'token_field',
|
41
|
'entities[node]' => '1',
|
42
|
'code[value]' => '<div class="token-class">[node:title]</span>',
|
43
|
'use_token' => '1',
|
44
|
);
|
45
|
$php_field = array(
|
46
|
'name' => 'PHP field',
|
47
|
'field' => 'php_field',
|
48
|
'entities[node]' => '1',
|
49
|
'code[value]' => "<?php echo 'I am a PHP field'; ?>",
|
50
|
'use_token' => '0',
|
51
|
);
|
52
|
$this->dsCreateCodeField($token_field);
|
53
|
$this->dsCreateCodeField($php_field);
|
54
|
|
55
|
// Select layout.
|
56
|
$this->dsSelectLayout();
|
57
|
|
58
|
// Configure fields.
|
59
|
$fields = array(
|
60
|
'fields[token_field][region]' => 'header',
|
61
|
'fields[php_field][region]' => 'left',
|
62
|
'fields[body][region]' => 'right',
|
63
|
'fields[node_link][region]' => 'footer',
|
64
|
'fields[body][label]' => $label,
|
65
|
'fields[submitted_by][region]' => 'header',
|
66
|
);
|
67
|
$this->dsConfigureUI($fields);
|
68
|
|
69
|
return $node;
|
70
|
}
|
71
|
|
72
|
/**
|
73
|
* Utility function to clear field settings.
|
74
|
*/
|
75
|
function entitiesClearFieldSettings() {
|
76
|
db_query('TRUNCATE {ds_field_settings}');
|
77
|
cache_clear_all('ds_fields:', 'cache', TRUE);
|
78
|
cache_clear_all('ds_field_settings', 'cache');
|
79
|
}
|
80
|
|
81
|
/**
|
82
|
* Set the label.
|
83
|
*/
|
84
|
function entitiesSetLabelClass($label, $text = '', $class = '', $hide_colon = FALSE) {
|
85
|
$edit = array(
|
86
|
'fields[body][label]' => $label,
|
87
|
);
|
88
|
if (!empty($text)) {
|
89
|
$edit['fields[body][settings_edit_form][settings][ft][lb]'] = $text;
|
90
|
}
|
91
|
if (!empty($class)) {
|
92
|
$edit['fields[body][settings_edit_form][settings][ft][classes][]'] = $class;
|
93
|
}
|
94
|
if ($hide_colon) {
|
95
|
$edit['fields[body][settings_edit_form][settings][ft][lb-col]'] = '1';
|
96
|
}
|
97
|
$this->dsEditFormatterSettings($edit);
|
98
|
}
|
99
|
|
100
|
/**
|
101
|
* Test basic node display fields.
|
102
|
*/
|
103
|
function testDSNodeEntity() {
|
104
|
|
105
|
$node = $this->entitiesTestSetup();
|
106
|
$node_author = user_load($node->uid);
|
107
|
|
108
|
// Look at node and verify token and block field.
|
109
|
$this->drupalGet('node/' . $node->nid);
|
110
|
$this->assertRaw('view-mode-full', 'Template file found (in full view mode)');
|
111
|
$this->assertRaw('<div class="token-class">' . $node->title . '</span>', t('Token field found'));
|
112
|
$this->assertRaw('I am a PHP field', t('PHP field found'));
|
113
|
$this->assertRaw('group-header', 'Template found (region header)');
|
114
|
$this->assertRaw('group-footer', 'Template found (region footer)');
|
115
|
$this->assertRaw('group-left', 'Template found (region left)');
|
116
|
$this->assertRaw('group-right', 'Template found (region right)');
|
117
|
$this->assertPattern('/<div[^>]*>Submitted[^<]*<a[^>]+href="' . preg_quote(base_path(), '/') . 'user\/' . $node_author->uid . '"[^>]*>' . check_plain($node_author->name) . '<\/a>.<\/div>/', t('Submitted by line found'));
|
118
|
|
119
|
// Configure teaser layout.
|
120
|
$teaser = array(
|
121
|
'additional_settings[layout]' => 'ds_2col',
|
122
|
);
|
123
|
$teaser_assert = array(
|
124
|
'regions' => array(
|
125
|
'left' => '<td colspan="8">' . t('Left') . '</td>',
|
126
|
'right' => '<td colspan="8">' . t('Right') . '</td>',
|
127
|
),
|
128
|
);
|
129
|
$this->dsSelectLayout($teaser, $teaser_assert, 'admin/structure/types/manage/article/display/teaser');
|
130
|
|
131
|
$fields = array(
|
132
|
'fields[token_field][region]' => 'left',
|
133
|
'fields[php_field][region]' => 'left',
|
134
|
'fields[body][region]' => 'right',
|
135
|
'fields[links][region]' => 'right',
|
136
|
);
|
137
|
$this->dsConfigureUI($fields, 'admin/structure/types/manage/article/display/teaser');
|
138
|
|
139
|
// Switch view mode on full node page.
|
140
|
$edit = array('ds_switch' => 'teaser');
|
141
|
$this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
|
142
|
$this->assertRaw('view-mode-teaser', 'Switched to teaser mode');
|
143
|
$this->assertRaw('group-left', 'Template found (region left)');
|
144
|
$this->assertRaw('group-right', 'Template found (region right)');
|
145
|
$this->assertNoRaw('group-header', 'Template found (no region header)');
|
146
|
$this->assertNoRaw('group-footer', 'Template found (no region footer)');
|
147
|
|
148
|
$edit = array('ds_switch' => '');
|
149
|
$this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
|
150
|
$this->assertRaw('view-mode-full', 'Switched to full mode again');
|
151
|
|
152
|
// Test all options of a block field.
|
153
|
$block = array(
|
154
|
'name' => 'Test block field',
|
155
|
'field' => 'test_block_field',
|
156
|
'entities[node]' => '1',
|
157
|
'block' => 'node|recent',
|
158
|
'block_render' => DS_BLOCK_TEMPLATE,
|
159
|
);
|
160
|
$this->dsCreateBlockField($block);
|
161
|
$fields = array(
|
162
|
'fields[test_block_field][region]' => 'left',
|
163
|
'fields[token_field][region]' => 'hidden',
|
164
|
'fields[php_field][region]' => 'hidden',
|
165
|
'fields[body][region]' => 'hidden',
|
166
|
'fields[links][region]' => 'hidden',
|
167
|
);
|
168
|
$this->dsConfigureUI($fields);
|
169
|
$this->drupalGet('node/' . $node->nid);
|
170
|
$this->assertRaw('<h2>Recent content</h2>');
|
171
|
|
172
|
$block = array(
|
173
|
'block_render' => DS_BLOCK_TITLE_CONTENT,
|
174
|
);
|
175
|
$this->dsCreateBlockField($block, 'admin/structure/ds/fields/manage_block/test_block_field', FALSE);
|
176
|
$this->drupalGet('node/' . $node->nid);
|
177
|
$this->assertNoRaw('<h2>Recent content</h2>');
|
178
|
$this->assertRaw('Recent content');
|
179
|
|
180
|
$block = array(
|
181
|
'block_render' => DS_BLOCK_CONTENT,
|
182
|
);
|
183
|
$this->dsCreateBlockField($block, 'admin/structure/ds/fields/manage_block/test_block_field', FALSE);
|
184
|
$this->drupalGet('node/' . $node->nid);
|
185
|
$this->assertNoRaw('<h2>Recent content</h2>');
|
186
|
$this->assertNoRaw('Recent content');
|
187
|
|
188
|
// Remove the page title (we'll use the switch view mode functionality too for this).
|
189
|
$edit = array('additional_settings[ds_page_title][ds_page_title_options][page_option_type]' => '1');
|
190
|
$this->dsConfigureUI($edit, 'admin/structure/types/manage/article/display/teaser');
|
191
|
$this->drupalGet('node/' . $node->nid);
|
192
|
$this->assertRaw('<h1 class="title" id="page-title">
|
193
|
'. $node->title . ' </h1>');
|
194
|
$edit = array('ds_switch' => 'teaser');
|
195
|
$this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
|
196
|
$this->drupalGet('node/' . $node->nid);
|
197
|
$this->assertNoRaw('<h1 class="title" id="page-title">
|
198
|
'. $node->title . ' </h1>');
|
199
|
|
200
|
// Use page title substitutions.
|
201
|
$edit = array('additional_settings[ds_page_title][ds_page_title_options][page_option_type]' => '2', 'additional_settings[ds_page_title][ds_page_title_options][page_option_title]' => 'Change title: %node:type');
|
202
|
$this->dsConfigureUI($edit, 'admin/structure/types/manage/article/display/teaser');
|
203
|
$this->drupalGet('node/' . $node->nid);
|
204
|
$this->assertRaw('<h1 class="title" id="page-title">
|
205
|
Change title: '. $node->type . ' </h1>');
|
206
|
$edit = array('additional_settings[ds_page_title][ds_page_title_options][page_option_type]' => '0');
|
207
|
$this->dsConfigureUI($edit, 'admin/structure/types/manage/article/display/teaser');
|
208
|
|
209
|
// Go to home page, page title shouldn't bleed here
|
210
|
// see http://drupal.org/node/1446554.
|
211
|
$edit = array('ds_switch' => '');
|
212
|
$this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
|
213
|
$edit = array('additional_settings[ds_page_title][ds_page_title_options][page_option_type]' => '2', 'additional_settings[ds_page_title][ds_page_title_options][page_option_title]' => 'Bleed title: %node:type');
|
214
|
$this->dsConfigureUI($edit, 'admin/structure/types/manage/article/display');
|
215
|
$this->drupalGet('node/' . $node->nid);
|
216
|
$this->assertRaw('<h1 class="title" id="page-title">
|
217
|
Bleed title: article </h1>');
|
218
|
$this->drupalGet('node');
|
219
|
$this->assertNoText('Bleed title');
|
220
|
|
221
|
// Test revisions. Enable the revision view mode
|
222
|
$edit = array('additional_settings[modes][view_modes_custom][revision]' => '1');
|
223
|
$this->drupalPost('admin/structure/types/manage/article/display', $edit, t('Save'));
|
224
|
|
225
|
// Select layout and configure fields.
|
226
|
$edit = array(
|
227
|
'additional_settings[layout]' => 'ds_2col',
|
228
|
);
|
229
|
$assert = array(
|
230
|
'regions' => array(
|
231
|
'left' => '<td colspan="8">' . t('Left') . '</td>',
|
232
|
'right' => '<td colspan="8">' . t('Right') . '</td>',
|
233
|
),
|
234
|
);
|
235
|
$this->dsSelectLayout($edit, $assert, 'admin/structure/types/manage/article/display/revision');
|
236
|
$edit = array(
|
237
|
'fields[body][region]' => 'left',
|
238
|
'fields[links][region]' => 'right',
|
239
|
'fields[author][region]' => 'right',
|
240
|
);
|
241
|
$this->dsConfigureUI($edit, 'admin/structure/types/manage/article/display/revision');
|
242
|
|
243
|
// Create revision of the node.
|
244
|
$edit = array(
|
245
|
'revision' => TRUE,
|
246
|
'log' => 'Test revision',
|
247
|
);
|
248
|
$this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
|
249
|
$this->assertText('Revisions');
|
250
|
|
251
|
// Assert revision is using 2 col template.
|
252
|
$this->drupalGet('node/' . $node->nid . '/revisions/1/view');
|
253
|
$this->assertText('Body:', 'Body label');
|
254
|
|
255
|
// Change title of revision.
|
256
|
$edit = array('additional_settings[ds_page_title][ds_page_title_options][page_option_type]' => '2', 'additional_settings[ds_page_title][ds_page_title_options][page_option_title]' => 'Custom revision title');
|
257
|
|
258
|
$this->dsConfigureUI($edit, 'admin/structure/types/manage/article/display/revision');
|
259
|
$this->drupalGet('node/' . $node->nid . '/revisions/1/view');
|
260
|
$this->assertText('Custom revision title', 'Custom title on revision view mode');
|
261
|
|
262
|
// Assert full view is using stacked template.
|
263
|
$this->drupalGet('node/' . $node->nid);
|
264
|
$this->assertNoText('Body:', 'Body label');
|
265
|
|
266
|
// Test formatter limit on article with tags.
|
267
|
$edit = array(
|
268
|
'ds_switch' => '',
|
269
|
'field_tags[und]' => 'Tag 1, Tag 2'
|
270
|
);
|
271
|
$this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
|
272
|
$edit = array(
|
273
|
'fields[field_tags][region]' => 'right',
|
274
|
);
|
275
|
$this->dsConfigureUI($edit, 'admin/structure/types/manage/article/display');
|
276
|
$this->drupalGet('node/' . $node->nid);
|
277
|
$this->assertText('Tag 1');
|
278
|
$this->assertText('Tag 2');
|
279
|
$edit = array(
|
280
|
'fields[field_tags][format][limit]' => '1',
|
281
|
);
|
282
|
$this->dsConfigureUI($edit, 'admin/structure/types/manage/article/display');
|
283
|
$this->drupalGet('node/' . $node->nid);
|
284
|
$this->assertText('Tag 1');
|
285
|
$this->assertNoText('Tag 2');
|
286
|
|
287
|
// Test check_plain() on ds_render_field() with the title field.
|
288
|
$edit = array(
|
289
|
'fields[title][region]' => 'right',
|
290
|
);
|
291
|
$this->dsConfigureUI($edit, 'admin/structure/types/manage/article/display');
|
292
|
$edit = array(
|
293
|
'title' => 'Hi, I am an article <script>alert(\'with a javascript tag in the title\');</script>',
|
294
|
);
|
295
|
$this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
|
296
|
$this->drupalGet('node/' . $node->nid);
|
297
|
$this->assertRaw('<h2>Hi, I am an article <script>alert('with a javascript tag in the title');</script></h2>');
|
298
|
}
|
299
|
|
300
|
/**
|
301
|
* Tests on field templates.
|
302
|
*/
|
303
|
function testDSFieldTemplate() {
|
304
|
|
305
|
// Get a node.
|
306
|
$node = $this->entitiesTestSetup('hidden');
|
307
|
$body_field = $node->body[$node->language][0]['value'];
|
308
|
|
309
|
// -------------------------
|
310
|
// Default theming function.
|
311
|
// -------------------------
|
312
|
$this->drupalGet('node/' . $node->nid);
|
313
|
$this->assertRaw("<div class=\"field field-name-body field-type-text-with-summary field-label-hidden\"><div class=\"field-items\"><div class=\"field-item even\" property=\"content:encoded\"><p>" . $body_field . "</p>
|
314
|
</div></div></div>");
|
315
|
|
316
|
$this->entitiesSetLabelClass('above');
|
317
|
$this->drupalGet('node/' . $node->nid);
|
318
|
$this->assertRaw("<div class=\"field field-name-body field-type-text-with-summary field-label-above\"><div class=\"field-label\">Body: </div><div class=\"field-items\"><div class=\"field-item even\" property=\"content:encoded\"><p>" . $body_field . "</p>
|
319
|
</div></div></div>");
|
320
|
|
321
|
$this->entitiesSetLabelClass('above', 'My body');
|
322
|
$this->drupalGet('node/' . $node->nid);
|
323
|
$this->assertRaw("<div class=\"field field-name-body field-type-text-with-summary field-label-above\"><div class=\"field-label\">My body: </div><div class=\"field-items\"><div class=\"field-item even\" property=\"content:encoded\"><p>" . $body_field . "</p>
|
324
|
</div></div></div>");
|
325
|
|
326
|
$this->entitiesSetLabelClass('hidden', '', 'test_field_class');
|
327
|
$this->drupalGet('node/' . $node->nid);
|
328
|
$this->assertRaw("<div class=\"field field-name-body field-type-text-with-summary field-label-hidden test_field_class\"><div class=\"field-items\"><div class=\"field-item even\" property=\"content:encoded\"><p>" . $body_field . "</p>
|
329
|
</div></div></div>");
|
330
|
|
331
|
$this->entitiesClearFieldSettings();
|
332
|
|
333
|
// -----------------------
|
334
|
// Reset theming function.
|
335
|
// -----------------------
|
336
|
$edit = array(
|
337
|
'additional_settings[fs1][ft-default]' => 'theme_ds_field_reset',
|
338
|
);
|
339
|
$this->drupalPost('admin/structure/ds/list/extras', $edit, t('Save configuration'));
|
340
|
$this->drupalGet('node/' . $node->nid);
|
341
|
$this->assertRaw("<div class=\"group-right\">
|
342
|
<p>" . $body_field . "</p>");
|
343
|
|
344
|
$this->entitiesSetLabelClass('above');
|
345
|
$this->drupalGet('node/' . $node->nid);
|
346
|
$this->assertRaw("<div class=\"group-right\">
|
347
|
<div class=\"label-above\">Body: </div><p>" . $body_field . "</p>");
|
348
|
|
349
|
$this->entitiesSetLabelClass('inline');
|
350
|
$this->drupalGet('node/' . $node->nid);
|
351
|
$this->assertRaw("<div class=\"group-right\">
|
352
|
<div class=\"label-inline\">Body: </div><p>" . $body_field . "</p>");
|
353
|
|
354
|
$this->entitiesSetLabelClass('above', 'My body');
|
355
|
$this->drupalGet('node/' . $node->nid);
|
356
|
$this->assertRaw("<div class=\"group-right\">
|
357
|
<div class=\"label-above\">My body: </div><p>" . $body_field . "</p>");
|
358
|
|
359
|
$this->entitiesSetLabelClass('inline', 'My body');
|
360
|
$this->drupalGet('node/' . $node->nid);
|
361
|
$this->assertRaw("<div class=\"group-right\">
|
362
|
<div class=\"label-inline\">My body: </div><p>" . $body_field . "</p>");
|
363
|
|
364
|
variable_set('ft-kill-colon', TRUE);
|
365
|
$this->refreshVariables();
|
366
|
$this->drupalGet('node/' . $node->nid);
|
367
|
$this->assertRaw("<div class=\"group-right\">
|
368
|
<div class=\"label-inline\">My body</div><p>" . $body_field . "</p>");
|
369
|
|
370
|
$this->entitiesSetLabelClass('hidden');
|
371
|
$this->drupalGet('node/' . $node->nid);
|
372
|
$this->assertRaw("<div class=\"group-right\">
|
373
|
<p>" . $body_field . "</p>");
|
374
|
$this->entitiesClearFieldSettings();
|
375
|
|
376
|
// ----------------------
|
377
|
// Custom field function.
|
378
|
// ----------------------
|
379
|
|
380
|
// With outer wrapper.
|
381
|
$edit = array(
|
382
|
'fields[body][settings_edit_form][settings][ft][func]' => 'theme_ds_field_expert',
|
383
|
'fields[body][settings_edit_form][settings][ft][ow]' => '1',
|
384
|
'fields[body][settings_edit_form][settings][ft][ow-el]' => 'div',
|
385
|
);
|
386
|
$this->dsEditFormatterSettings($edit);
|
387
|
|
388
|
$this->drupalGet('node/' . $node->nid);
|
389
|
$this->assertRaw("<div class=\"group-right\">
|
390
|
<div><p>" . $body_field . "</p>
|
391
|
</div> </div>");
|
392
|
|
393
|
// With outer div wrapper and class.
|
394
|
$edit = array(
|
395
|
'fields[body][settings_edit_form][settings][ft][ow]' => '1',
|
396
|
'fields[body][settings_edit_form][settings][ft][ow-el]' => 'div',
|
397
|
'fields[body][settings_edit_form][settings][ft][ow-cl]' => 'ow-class'
|
398
|
);
|
399
|
$this->dsEditFormatterSettings($edit);
|
400
|
$this->drupalGet('node/' . $node->nid);
|
401
|
$this->assertRaw("<div class=\"group-right\">
|
402
|
<div class=\"ow-class\"><p>" . $body_field . "</p>
|
403
|
</div> </div>");
|
404
|
|
405
|
// With outer span wrapper and class.
|
406
|
$edit = array(
|
407
|
'fields[body][settings_edit_form][settings][ft][ow]' => '1',
|
408
|
'fields[body][settings_edit_form][settings][ft][ow-el]' => 'span',
|
409
|
'fields[body][settings_edit_form][settings][ft][ow-cl]' => 'ow-class-2'
|
410
|
);
|
411
|
$this->dsEditFormatterSettings($edit);
|
412
|
$this->drupalGet('node/' . $node->nid);
|
413
|
$this->assertRaw("<div class=\"group-right\">
|
414
|
<span class=\"ow-class-2\"><p>" . $body_field . "</p>
|
415
|
</span> </div>");
|
416
|
|
417
|
// Clear field settings.
|
418
|
$this->entitiesClearFieldSettings();
|
419
|
|
420
|
// With outer wrapper and field items wrapper.
|
421
|
$edit = array(
|
422
|
'fields[body][settings_edit_form][settings][ft][func]' => 'theme_ds_field_expert',
|
423
|
'fields[body][settings_edit_form][settings][ft][ow]' => '1',
|
424
|
'fields[body][settings_edit_form][settings][ft][ow-el]' => 'div',
|
425
|
'fields[body][settings_edit_form][settings][ft][fis]' => '1',
|
426
|
'fields[body][settings_edit_form][settings][ft][fis-el]' => 'div'
|
427
|
);
|
428
|
$this->dsEditFormatterSettings($edit);
|
429
|
$this->drupalGet('node/' . $node->nid);
|
430
|
$this->assertRaw("<div class=\"group-right\">
|
431
|
<div><div><p>" . $body_field . "</p>
|
432
|
</div></div> </div>");
|
433
|
|
434
|
// With outer wrapper and field items div wrapper with class.
|
435
|
$edit = array(
|
436
|
'fields[body][settings_edit_form][settings][ft][ow]' => '1',
|
437
|
'fields[body][settings_edit_form][settings][ft][ow-el]' => 'div',
|
438
|
'fields[body][settings_edit_form][settings][ft][ow-el]' => 'div',
|
439
|
'fields[body][settings_edit_form][settings][ft][fis]' => '1',
|
440
|
'fields[body][settings_edit_form][settings][ft][fis-el]' => 'div',
|
441
|
'fields[body][settings_edit_form][settings][ft][fis-cl]' => 'fi-class'
|
442
|
);
|
443
|
$this->dsEditFormatterSettings($edit);
|
444
|
$this->drupalGet('node/' . $node->nid);
|
445
|
$this->assertRaw("<div class=\"group-right\">
|
446
|
<div><div class=\"fi-class\"><p>" . $body_field . "</p>
|
447
|
</div></div> </div>");
|
448
|
|
449
|
// With outer wrapper and field items span wrapper and class.
|
450
|
$edit = array(
|
451
|
'fields[body][settings_edit_form][settings][ft][ow]' => '1',
|
452
|
'fields[body][settings_edit_form][settings][ft][ow-el]' => 'div',
|
453
|
'fields[body][settings_edit_form][settings][ft][fis]' => '1',
|
454
|
'fields[body][settings_edit_form][settings][ft][fis-el]' => 'span',
|
455
|
'fields[body][settings_edit_form][settings][ft][fis-cl]' => 'fi-class'
|
456
|
);
|
457
|
$this->dsEditFormatterSettings($edit);
|
458
|
$this->drupalGet('node/' . $node->nid);
|
459
|
$this->assertRaw("<div class=\"group-right\">
|
460
|
<div><span class=\"fi-class\"><p>" . $body_field . "</p>
|
461
|
</span></div> </div>");
|
462
|
|
463
|
// With outer wrapper class and field items span wrapper and class.
|
464
|
$edit = array(
|
465
|
'fields[body][settings_edit_form][settings][ft][ow]' => '1',
|
466
|
'fields[body][settings_edit_form][settings][ft][ow-el]' => 'div',
|
467
|
'fields[body][settings_edit_form][settings][ft][ow-cl]' => 'ow-class',
|
468
|
'fields[body][settings_edit_form][settings][ft][fis]' => '1',
|
469
|
'fields[body][settings_edit_form][settings][ft][fis-el]' => 'span',
|
470
|
'fields[body][settings_edit_form][settings][ft][fis-cl]' => 'fi-class'
|
471
|
);
|
472
|
$this->dsEditFormatterSettings($edit);
|
473
|
$this->drupalGet('node/' . $node->nid);
|
474
|
$this->assertRaw("<div class=\"group-right\">
|
475
|
<div class=\"ow-class\"><span class=\"fi-class\"><p>" . $body_field . "</p>
|
476
|
</span></div> </div>");
|
477
|
|
478
|
// With outer wrapper span class and field items span wrapper and class.
|
479
|
$edit = array(
|
480
|
'fields[body][settings_edit_form][settings][ft][ow]' => '1',
|
481
|
'fields[body][settings_edit_form][settings][ft][ow-el]' => 'span',
|
482
|
'fields[body][settings_edit_form][settings][ft][ow-cl]' => 'ow-class',
|
483
|
'fields[body][settings_edit_form][settings][ft][fis]' => '1',
|
484
|
'fields[body][settings_edit_form][settings][ft][fis-el]' => 'span',
|
485
|
'fields[body][settings_edit_form][settings][ft][fis-cl]' => 'fi-class-2'
|
486
|
);
|
487
|
$this->dsEditFormatterSettings($edit);
|
488
|
$this->drupalGet('node/' . $node->nid);
|
489
|
$this->assertRaw("<div class=\"group-right\">
|
490
|
<span class=\"ow-class\"><span class=\"fi-class-2\"><p>" . $body_field . "</p>
|
491
|
</span></span> </div>");
|
492
|
|
493
|
// Clear field settings.
|
494
|
$this->entitiesClearFieldSettings();
|
495
|
|
496
|
// With field item div wrapper.
|
497
|
$edit = array(
|
498
|
'fields[body][settings_edit_form][settings][ft][func]' => 'theme_ds_field_expert',
|
499
|
'fields[body][settings_edit_form][settings][ft][fi]' => '1',
|
500
|
);
|
501
|
$this->dsEditFormatterSettings($edit);
|
502
|
$this->drupalGet('node/' . $node->nid);
|
503
|
$this->assertRaw("<div class=\"group-right\">
|
504
|
<div><p>" . $body_field . "</p>
|
505
|
</div> </div>");
|
506
|
|
507
|
// With field item span wrapper.
|
508
|
$edit = array(
|
509
|
'fields[body][settings_edit_form][settings][ft][fi]' => '1',
|
510
|
'fields[body][settings_edit_form][settings][ft][fi-el]' => 'span',
|
511
|
);
|
512
|
$this->dsEditFormatterSettings($edit);
|
513
|
$this->drupalGet('node/' . $node->nid);
|
514
|
$this->assertRaw("<div class=\"group-right\">
|
515
|
<span><p>" . $body_field . "</p>
|
516
|
</span> </div>");
|
517
|
|
518
|
// With field item span wrapper and class and odd even.
|
519
|
$edit = array(
|
520
|
'fields[body][settings_edit_form][settings][ft][fi]' => '1',
|
521
|
'fields[body][settings_edit_form][settings][ft][fi-el]' => 'span',
|
522
|
'fields[body][settings_edit_form][settings][ft][fi-cl]' => 'fi-class',
|
523
|
'fields[body][settings_edit_form][settings][ft][fi-odd-even]' => '1',
|
524
|
'fields[body][settings_edit_form][settings][ft][fi-first-last]' => '1',
|
525
|
);
|
526
|
$this->dsEditFormatterSettings($edit);
|
527
|
$this->drupalGet('node/' . $node->nid);
|
528
|
$this->assertRaw("<div class=\"group-right\">
|
529
|
<span class=\"even fi-class\"><p>" . $body_field . "</p>
|
530
|
</span> </div>");
|
531
|
|
532
|
// With fis and fi.
|
533
|
$edit = array(
|
534
|
'fields[body][settings_edit_form][settings][ft][fis]' => '1',
|
535
|
'fields[body][settings_edit_form][settings][ft][fis-el]' => 'div',
|
536
|
'fields[body][settings_edit_form][settings][ft][fis-cl]' => 'fi-class-2',
|
537
|
'fields[body][settings_edit_form][settings][ft][fi]' => '1',
|
538
|
'fields[body][settings_edit_form][settings][ft][fi-el]' => 'div',
|
539
|
'fields[body][settings_edit_form][settings][ft][fi-cl]' => 'fi-class',
|
540
|
'fields[body][settings_edit_form][settings][ft][fi-odd-even]' => '1',
|
541
|
'fields[body][settings_edit_form][settings][ft][fi-first-last]' => '1',
|
542
|
);
|
543
|
$this->dsEditFormatterSettings($edit);
|
544
|
$this->drupalGet('node/' . $node->nid);
|
545
|
$this->assertRaw("<div class=\"group-right\">
|
546
|
<div class=\"fi-class-2\"><div class=\"even fi-class\"><p>" . $body_field . "</p>
|
547
|
</div></div> </div>");
|
548
|
// With all wrappers.
|
549
|
$edit = array(
|
550
|
'fields[body][settings_edit_form][settings][ft][ow]' => '1',
|
551
|
'fields[body][settings_edit_form][settings][ft][ow-el]' => 'div',
|
552
|
'fields[body][settings_edit_form][settings][ft][ow-cl]' => 'ow-class',
|
553
|
'fields[body][settings_edit_form][settings][ft][fis]' => '1',
|
554
|
'fields[body][settings_edit_form][settings][ft][fis-el]' => 'div',
|
555
|
'fields[body][settings_edit_form][settings][ft][fis-cl]' => 'fi-class-2',
|
556
|
'fields[body][settings_edit_form][settings][ft][fi]' => '1',
|
557
|
'fields[body][settings_edit_form][settings][ft][fi-el]' => 'span',
|
558
|
'fields[body][settings_edit_form][settings][ft][fi-cl]' => 'fi-class',
|
559
|
'fields[body][settings_edit_form][settings][ft][fi-odd-even]' => '1',
|
560
|
'fields[body][settings_edit_form][settings][ft][fi-first-last]' => '1',
|
561
|
);
|
562
|
$this->dsEditFormatterSettings($edit);
|
563
|
$this->drupalGet('node/' . $node->nid);
|
564
|
$this->assertRaw("<div class=\"group-right\">
|
565
|
<div class=\"ow-class\"><div class=\"fi-class-2\"><span class=\"even fi-class\"><p>" . $body_field . "</p>
|
566
|
</span></div></div> </div>");
|
567
|
|
568
|
// With all wrappers and attributes.
|
569
|
$edit = array(
|
570
|
'fields[body][settings_edit_form][settings][ft][ow]' => '1',
|
571
|
'fields[body][settings_edit_form][settings][ft][ow-el]' => 'div',
|
572
|
'fields[body][settings_edit_form][settings][ft][ow-cl]' => 'ow-class',
|
573
|
'fields[body][settings_edit_form][settings][ft][ow-at]' => 'name="ow-att"',
|
574
|
'fields[body][settings_edit_form][settings][ft][fis]' => '1',
|
575
|
'fields[body][settings_edit_form][settings][ft][fis-el]' => 'div',
|
576
|
'fields[body][settings_edit_form][settings][ft][fis-cl]' => 'fi-class-2',
|
577
|
'fields[body][settings_edit_form][settings][ft][fis-at]' => 'name="fis-att"',
|
578
|
'fields[body][settings_edit_form][settings][ft][fi]' => '1',
|
579
|
'fields[body][settings_edit_form][settings][ft][fi-el]' => 'span',
|
580
|
'fields[body][settings_edit_form][settings][ft][fi-cl]' => 'fi-class',
|
581
|
'fields[body][settings_edit_form][settings][ft][fi-at]' => 'name="fi-at"',
|
582
|
);
|
583
|
$this->dsEditFormatterSettings($edit);
|
584
|
$this->drupalGet('node/' . $node->nid);
|
585
|
$this->assertRaw("<div class=\"group-right\">
|
586
|
<div class=\"ow-class\" name=\"ow-att\"><div class=\"fi-class-2\" name=\"fis-att\"><span class=\"even fi-class\" name=\"fi-at\"><p>" . $body_field . "</p>
|
587
|
</span></div></div> </div>");
|
588
|
|
589
|
// Remove attributes.
|
590
|
$edit = array(
|
591
|
'fields[body][settings_edit_form][settings][ft][ow]' => '1',
|
592
|
'fields[body][settings_edit_form][settings][ft][ow-el]' => 'div',
|
593
|
'fields[body][settings_edit_form][settings][ft][ow-cl]' => 'ow-class',
|
594
|
'fields[body][settings_edit_form][settings][ft][ow-at]' => '',
|
595
|
'fields[body][settings_edit_form][settings][ft][fis]' => '1',
|
596
|
'fields[body][settings_edit_form][settings][ft][fis-el]' => 'div',
|
597
|
'fields[body][settings_edit_form][settings][ft][fis-cl]' => 'fi-class-2',
|
598
|
'fields[body][settings_edit_form][settings][ft][fis-at]' => '',
|
599
|
'fields[body][settings_edit_form][settings][ft][fi]' => '1',
|
600
|
'fields[body][settings_edit_form][settings][ft][fi-el]' => 'span',
|
601
|
'fields[body][settings_edit_form][settings][ft][fi-cl]' => 'fi-class',
|
602
|
'fields[body][settings_edit_form][settings][ft][fi-at]' => '',
|
603
|
);
|
604
|
$this->dsEditFormatterSettings($edit);
|
605
|
|
606
|
// Label tests with custom function.
|
607
|
$this->entitiesSetLabelClass('above');
|
608
|
$this->drupalGet('node/' . $node->nid);
|
609
|
$this->assertRaw("<div class=\"group-right\">
|
610
|
<div class=\"ow-class\"><div class=\"label-above\">Body: </div><div class=\"fi-class-2\"><span class=\"even fi-class\"><p>" . $body_field . "</p>
|
611
|
</span></div></div> </div>");
|
612
|
|
613
|
$this->entitiesSetLabelClass('inline');
|
614
|
$this->drupalGet('node/' . $node->nid);
|
615
|
$this->assertRaw("<div class=\"group-right\">
|
616
|
<div class=\"ow-class\"><div class=\"label-inline\">Body: </div><div class=\"fi-class-2\"><span class=\"even fi-class\"><p>" . $body_field . "</p>
|
617
|
</span></div></div> </div>");
|
618
|
|
619
|
$this->entitiesSetLabelClass('above', 'My body');
|
620
|
$this->drupalGet('node/' . $node->nid);
|
621
|
$this->assertRaw("<div class=\"group-right\">
|
622
|
<div class=\"ow-class\"><div class=\"label-above\">My body: </div><div class=\"fi-class-2\"><span class=\"even fi-class\"><p>" . $body_field . "</p>
|
623
|
</span></div></div> </div>");
|
624
|
|
625
|
$this->entitiesSetLabelClass('inline', 'My body');
|
626
|
$this->drupalGet('node/' . $node->nid);
|
627
|
$this->assertRaw("<div class=\"group-right\">
|
628
|
<div class=\"ow-class\"><div class=\"label-inline\">My body: </div><div class=\"fi-class-2\"><span class=\"even fi-class\"><p>" . $body_field . "</p>
|
629
|
</span></div></div> </div>");
|
630
|
|
631
|
$this->entitiesSetLabelClass('inline', 'My body', '', TRUE);
|
632
|
$this->drupalGet('node/' . $node->nid);
|
633
|
$this->assertRaw("<div class=\"group-right\">
|
634
|
<div class=\"ow-class\"><div class=\"label-inline\">My body</div><div class=\"fi-class-2\"><span class=\"even fi-class\"><p>" . $body_field . "</p>
|
635
|
</span></div></div> </div>");
|
636
|
|
637
|
$this->entitiesSetLabelClass('hidden');
|
638
|
$this->drupalGet('node/' . $node->nid);
|
639
|
$this->assertRaw("<div class=\"group-right\">
|
640
|
<div class=\"ow-class\"><div class=\"fi-class-2\"><span class=\"even fi-class\"><p>" . $body_field . "</p>
|
641
|
</span></div></div> </div>");
|
642
|
|
643
|
// Test default classes on outer wrapper.
|
644
|
$edit = array(
|
645
|
'fields[body][settings_edit_form][settings][ft][ow]' => '1',
|
646
|
'fields[body][settings_edit_form][settings][ft][ow-el]' => 'div',
|
647
|
'fields[body][settings_edit_form][settings][ft][ow-cl]' => 'ow-class',
|
648
|
'fields[body][settings_edit_form][settings][ft][ow-def-cl]' => '1',
|
649
|
);
|
650
|
$this->dsEditFormatterSettings($edit);
|
651
|
$this->drupalGet('node/' . $node->nid);
|
652
|
$this->assertRaw("<div class=\"group-right\">
|
653
|
<div class=\"ow-class field field-name-body field-type-text-with-summary field-label-hidden\"><div class=\"fi-class-2\"><span class=\"even fi-class\"><p>" . $body_field . "</p>
|
654
|
</span></div></div> </div>");
|
655
|
|
656
|
// Test default attributes on field item.
|
657
|
$edit = array(
|
658
|
'fields[body][settings_edit_form][settings][ft][ow]' => '1',
|
659
|
'fields[body][settings_edit_form][settings][ft][ow-el]' => 'div',
|
660
|
'fields[body][settings_edit_form][settings][ft][ow-cl]' => 'ow-class',
|
661
|
'fields[body][settings_edit_form][settings][ft][ow-def-cl]' => '1',
|
662
|
'fields[body][settings_edit_form][settings][ft][fi-def-at]' => '1',
|
663
|
);
|
664
|
$this->dsEditFormatterSettings($edit);
|
665
|
$this->drupalGet('node/' . $node->nid);
|
666
|
$this->assertRaw("<div class=\"group-right\">
|
667
|
<div class=\"ow-class field field-name-body field-type-text-with-summary field-label-hidden\"><div class=\"fi-class-2\"><span class=\"even fi-class\" property=\"content:encoded\"><p>" . $body_field . "</p>
|
668
|
</span></div></div> </div>");
|
669
|
|
670
|
// Use the test field theming function to test that this function is
|
671
|
// registered in the theme registry through ds_extras_theme().
|
672
|
$edit = array(
|
673
|
'fields[body][settings_edit_form][settings][ft][func]' => 'ds_test_theming_function',
|
674
|
);
|
675
|
|
676
|
$this->dsEditFormatterSettings($edit);
|
677
|
$this->drupalGet('node/' . $node->nid);
|
678
|
$this->assertRaw("<div class=\"group-right\">
|
679
|
Testing field output through custom function </div>");
|
680
|
}
|
681
|
}
|