1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Tests Views UI Wizard.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* Views UI wizard tests.
|
10
|
*/
|
11
|
class ViewsUIWizardHelper extends DrupalWebTestCase {
|
12
|
|
13
|
/**
|
14
|
*
|
15
|
*/
|
16
|
function setUp() {
|
17
|
// Enable views_ui.
|
18
|
parent::setUp('views_ui');
|
19
|
|
20
|
// Create and log in a user with administer views permission.
|
21
|
$views_admin = $this->drupalCreateUser(array('administer views', 'administer blocks', 'bypass node access', 'access user profiles', 'view revisions'));
|
22
|
$this->drupalLogin($views_admin);
|
23
|
}
|
24
|
|
25
|
}
|
26
|
|
27
|
/**
|
28
|
* Tests creating views with the wizard and viewing them on the listing page.
|
29
|
*/
|
30
|
class ViewsUIWizardBasicTestCase extends ViewsUIWizardHelper {
|
31
|
|
32
|
/**
|
33
|
*
|
34
|
*/
|
35
|
public static function getInfo() {
|
36
|
return array(
|
37
|
'name' => 'Views UI wizard basic functionality',
|
38
|
'description' => 'Test creating basic views with the wizard and viewing them on the listing page.',
|
39
|
'group' => 'Views UI',
|
40
|
);
|
41
|
}
|
42
|
|
43
|
/**
|
44
|
*
|
45
|
*/
|
46
|
function testViewsWizardAndListing() {
|
47
|
// Check if we can access the main views admin page.
|
48
|
$this->drupalGet('admin/structure/views');
|
49
|
$this->assertText(t('Add new view'));
|
50
|
|
51
|
// Create a simple and not at all useful view.
|
52
|
$view1 = array();
|
53
|
$view1['human_name'] = $this->randomName(16);
|
54
|
$view1['name'] = strtolower($this->randomName(16));
|
55
|
$view1['description'] = $this->randomName(16);
|
56
|
$view1['page[create]'] = FALSE;
|
57
|
$this->drupalPost('admin/structure/views/add', $view1, t('Save & exit'));
|
58
|
$this->assertText(t('Your view was saved. You may edit it from the list below.'));
|
59
|
$this->assertText($view1['human_name']);
|
60
|
$this->assertText($view1['description']);
|
61
|
foreach (array('delete', 'clone', 'edit') as $operation) {
|
62
|
$this->assertLinkByHref(url('admin/structure/views/view/' . $view1['name'] . '/' . $operation));
|
63
|
}
|
64
|
|
65
|
// This view should not have a block.
|
66
|
$this->drupalGet('admin/structure/block');
|
67
|
$this->assertNoText('View: ' . $view1['human_name']);
|
68
|
|
69
|
// Create two nodes.
|
70
|
$node1 = $this->drupalCreateNode(array('type' => 'page'));
|
71
|
$node2 = $this->drupalCreateNode(array('type' => 'article'));
|
72
|
|
73
|
// Now create a page with simple node listing and an attached feed.
|
74
|
$view2 = array();
|
75
|
$view2['human_name'] = $this->randomName(16);
|
76
|
$view2['name'] = strtolower($this->randomName(16));
|
77
|
$view2['description'] = $this->randomName(16);
|
78
|
$view2['page[create]'] = 1;
|
79
|
$view2['page[title]'] = $this->randomName(16);
|
80
|
$view2['page[path]'] = $this->randomName(16);
|
81
|
$view2['page[feed]'] = 1;
|
82
|
$view2['page[feed_properties][path]'] = $this->randomName(16);
|
83
|
$this->drupalPost('admin/structure/views/add', $view2, t('Save & exit'));
|
84
|
|
85
|
// Since the view has a page, we expect to be automatically redirected to
|
86
|
// it.
|
87
|
$this->assertUrl($view2['page[path]']);
|
88
|
$this->assertText($view2['page[title]']);
|
89
|
$this->assertText($node1->title);
|
90
|
$this->assertText($node2->title);
|
91
|
|
92
|
// Check if we have the feed.
|
93
|
$this->assertLinkByHref(url($view2['page[feed_properties][path]']));
|
94
|
$this->drupalGet($view2['page[feed_properties][path]']);
|
95
|
$this->assertRaw('<rss version="2.0"');
|
96
|
// The feed should have the same title and nodes as the page.
|
97
|
$this->assertText($view2['page[title]']);
|
98
|
$this->assertRaw(url('node/' . $node1->nid, array('absolute' => TRUE)));
|
99
|
$this->assertText($node1->title);
|
100
|
$this->assertRaw(url('node/' . $node2->nid, array('absolute' => TRUE)));
|
101
|
$this->assertText($node2->title);
|
102
|
|
103
|
// Go back to the views page and check if this view is there.
|
104
|
$this->drupalGet('admin/structure/views');
|
105
|
$this->assertText($view2['human_name']);
|
106
|
$this->assertText($view2['description']);
|
107
|
$this->assertLinkByHref(url($view2['page[path]']));
|
108
|
|
109
|
// This view should not have a block.
|
110
|
$this->drupalGet('admin/structure/block');
|
111
|
$this->assertNoText('View: ' . $view2['human_name']);
|
112
|
|
113
|
// Create a view with a page and a block, and filter the listing.
|
114
|
$view3 = array();
|
115
|
$view3['human_name'] = $this->randomName(16);
|
116
|
$view3['name'] = strtolower($this->randomName(16));
|
117
|
$view3['description'] = $this->randomName(16);
|
118
|
$view3['show[wizard_key]'] = 'node';
|
119
|
$view3['show[type]'] = 'page';
|
120
|
$view3['page[create]'] = 1;
|
121
|
$view3['page[title]'] = $this->randomName(16);
|
122
|
$view3['page[path]'] = $this->randomName(16);
|
123
|
$view3['block[create]'] = 1;
|
124
|
$view3['block[title]'] = $this->randomName(16);
|
125
|
$this->drupalPost('admin/structure/views/add', $view3, t('Save & exit'));
|
126
|
|
127
|
// Make sure the view only displays the node we expect.
|
128
|
$this->assertUrl($view3['page[path]']);
|
129
|
$this->assertText($view3['page[title]']);
|
130
|
$this->assertText($node1->title);
|
131
|
$this->assertNoText($node2->title);
|
132
|
|
133
|
// Go back to the views page and check if this view is there.
|
134
|
$this->drupalGet('admin/structure/views');
|
135
|
$this->assertText($view3['human_name']);
|
136
|
$this->assertText($view3['description']);
|
137
|
$this->assertLinkByHref(url($view3['page[path]']));
|
138
|
|
139
|
// Put the block into the first sidebar region.
|
140
|
$this->drupalGet('admin/structure/block');
|
141
|
$this->assertText('View: ' . $view3['human_name']);
|
142
|
$edit = array();
|
143
|
$edit["blocks[views_{$view3['name']}-block][region]"] = 'sidebar_first';
|
144
|
$this->drupalPost('admin/structure/block', $edit, t('Save blocks'));
|
145
|
|
146
|
// Visit a random page (not the one that displays the view itself) and look
|
147
|
// for the expected node title in the block.
|
148
|
$this->drupalGet('user');
|
149
|
$this->assertText($node1->title);
|
150
|
$this->assertNoText($node2->title);
|
151
|
|
152
|
// Check if the export screen works.
|
153
|
$this->drupalGet('admin/structure/views/view/' . $view3['name'] . '/export');
|
154
|
$this->assertRaw('$view = new view();');
|
155
|
$this->assertRaw($view3['human_name']);
|
156
|
$this->assertRaw($view3['description']);
|
157
|
|
158
|
// Make sure the listing page doesn't show disabled default views.
|
159
|
$this->assertNoText('tracker', t('Default tracker view does not show on the listing page.'));
|
160
|
}
|
161
|
|
162
|
}
|
163
|
|
164
|
/**
|
165
|
* Tests enabling, disabling, and reverting default views via the listing page.
|
166
|
*/
|
167
|
class ViewsUIWizardDefaultViewsTestCase extends ViewsUIWizardHelper {
|
168
|
|
169
|
/**
|
170
|
*
|
171
|
*/
|
172
|
public static function getInfo() {
|
173
|
return array(
|
174
|
'name' => 'Views UI default views functionality',
|
175
|
'description' => 'Test enabling, disabling, and reverting default views via the listing page.',
|
176
|
'group' => 'Views UI',
|
177
|
);
|
178
|
}
|
179
|
|
180
|
/**
|
181
|
* Tests default views.
|
182
|
*/
|
183
|
function testDefaultViews() {
|
184
|
// Make sure the front page view starts off as disabled (does not appear on
|
185
|
// the listing page).
|
186
|
$edit_href = 'admin/structure/views/view/frontpage/edit';
|
187
|
$this->drupalGet('admin/structure/views');
|
188
|
// @todo Disabled default views do now appear on the front page. Test this
|
189
|
// behavior with templates instead.
|
190
|
// $this->assertNoLinkByHref($edit_href);
|
191
|
// Enable the front page view, and make sure it is now visible on the main
|
192
|
// listing page.
|
193
|
$this->drupalGet('admin/structure/views/templates');
|
194
|
$this->clickViewsOperationLink(t('Enable'), '/frontpage/');
|
195
|
$this->assertUrl('admin/structure/views');
|
196
|
$this->assertLinkByHref($edit_href);
|
197
|
|
198
|
// It should not be possible to revert the view yet.
|
199
|
$this->assertNoLink(t('Revert'));
|
200
|
$revert_href = 'admin/structure/views/view/frontpage/revert';
|
201
|
$this->assertNoLinkByHref($revert_href);
|
202
|
|
203
|
// Edit the view and change the title. Make sure that the new title is
|
204
|
// displayed.
|
205
|
$new_title = $this->randomName(16);
|
206
|
$edit = array('title' => $new_title);
|
207
|
$this->drupalPost('admin/structure/views/nojs/display/frontpage/page/title', $edit, t('Apply'));
|
208
|
$this->drupalPost('admin/structure/views/view/frontpage/edit/page', array(), t('Save'));
|
209
|
$this->drupalGet('frontpage');
|
210
|
$this->assertText($new_title);
|
211
|
|
212
|
// It should now be possible to revert the view. Do that, and make sure the
|
213
|
// view title we added above no longer is displayed.
|
214
|
$this->drupalGet('admin/structure/views');
|
215
|
$this->assertLink(t('Revert'));
|
216
|
$this->assertLinkByHref($revert_href);
|
217
|
$this->drupalPost($revert_href, array(), t('Revert'));
|
218
|
$this->drupalGet('frontpage');
|
219
|
$this->assertNoText($new_title);
|
220
|
|
221
|
// Now disable the view, and make sure it stops appearing on the main view
|
222
|
// listing page but instead goes back to displaying on the disabled views
|
223
|
// listing page.
|
224
|
// @todo Test this behavior with templates instead.
|
225
|
$this->drupalGet('admin/structure/views');
|
226
|
$this->clickViewsOperationLink(t('Disable'), '/frontpage/');
|
227
|
// $this->assertUrl('admin/structure/views');
|
228
|
// $this->assertNoLinkByHref($edit_href);
|
229
|
// The easiest way to verify it appears on the disabled views listing page
|
230
|
// is to try to click the "enable" link from there again.
|
231
|
$this->drupalGet('admin/structure/views/templates');
|
232
|
$this->clickViewsOperationLink(t('Enable'), '/frontpage/');
|
233
|
$this->assertUrl('admin/structure/views');
|
234
|
$this->assertLinkByHref($edit_href);
|
235
|
}
|
236
|
|
237
|
/**
|
238
|
* Click a link to perform an operation on a view.
|
239
|
*
|
240
|
* In general, we expect lots of links titled "enable" or "disable" on the
|
241
|
* various views listing pages, and they might have tokens in them. So we
|
242
|
* need special code to find the correct one to click.
|
243
|
*
|
244
|
* @param string $label
|
245
|
* Text between the anchor tags of the desired link.
|
246
|
* @param string $unique_href_part
|
247
|
* A unique string that is expected to occur within the href of the desired
|
248
|
* link. For example, if the link URL is expected to look like
|
249
|
* "admin/structure/views/view/frontpage/...", then "/frontpage/" could be
|
250
|
* passed as the expected unique string.
|
251
|
*
|
252
|
* @return string
|
253
|
* The page content that results from clicking on the link, or FALSE on
|
254
|
* failure. Failure also results in a failed assertion.
|
255
|
*/
|
256
|
function clickViewsOperationLink($label, $unique_href_part) {
|
257
|
$links = $this->xpath('//a[normalize-space(text())=:label]', array(':label' => $label));
|
258
|
foreach ($links as $link_index => $link) {
|
259
|
$position = strpos($link['href'], $unique_href_part);
|
260
|
if ($position !== FALSE) {
|
261
|
$index = $link_index;
|
262
|
break;
|
263
|
}
|
264
|
}
|
265
|
$this->assertTrue(isset($index), t('Link to "@label" containing @part found.', array('@label' => $label, '@part' => $unique_href_part)));
|
266
|
if (isset($index)) {
|
267
|
return $this->clickLink($label, $index);
|
268
|
}
|
269
|
else {
|
270
|
return FALSE;
|
271
|
}
|
272
|
}
|
273
|
|
274
|
}
|
275
|
|
276
|
/**
|
277
|
* Tests the ability of the views wizard to create views filtered by taxonomy.
|
278
|
*/
|
279
|
class ViewsUIWizardTaggedWithTestCase extends ViewsUIWizardHelper {
|
280
|
|
281
|
/**
|
282
|
*
|
283
|
*/
|
284
|
protected $node_type_with_tags;
|
285
|
|
286
|
/**
|
287
|
*
|
288
|
*/
|
289
|
protected $node_type_without_tags;
|
290
|
|
291
|
/**
|
292
|
*
|
293
|
*/
|
294
|
protected $tag_vocabulary;
|
295
|
|
296
|
/**
|
297
|
*
|
298
|
*/
|
299
|
protected $tag_field;
|
300
|
|
301
|
/**
|
302
|
*
|
303
|
*/
|
304
|
protected $tag_instance;
|
305
|
|
306
|
/**
|
307
|
*
|
308
|
*/
|
309
|
public static function getInfo() {
|
310
|
return array(
|
311
|
'name' => 'Views UI wizard taxonomy functionality',
|
312
|
'description' => 'Test the ability of the views wizard to create views filtered by taxonomy.',
|
313
|
'group' => 'Views UI',
|
314
|
);
|
315
|
}
|
316
|
|
317
|
/**
|
318
|
* {@inheritdoc}
|
319
|
*/
|
320
|
function setUp() {
|
321
|
parent::setUp();
|
322
|
|
323
|
// Create two content types. One will have an autocomplete tagging field,
|
324
|
// and one won't.
|
325
|
$this->node_type_with_tags = $this->drupalCreateContentType();
|
326
|
$this->node_type_without_tags = $this->drupalCreateContentType();
|
327
|
|
328
|
// Create the vocabulary for the tag field.
|
329
|
$this->tag_vocabulary = new stdClass();
|
330
|
$this->tag_vocabulary->name = 'Views testing tags';
|
331
|
$this->tag_vocabulary->machine_name = 'views_testing_tags';
|
332
|
taxonomy_vocabulary_save($this->tag_vocabulary);
|
333
|
|
334
|
// Create the tag field itself.
|
335
|
$this->tag_field = array(
|
336
|
'field_name' => 'field_views_testing_tags',
|
337
|
'type' => 'taxonomy_term_reference',
|
338
|
'cardinality' => FIELD_CARDINALITY_UNLIMITED,
|
339
|
'settings' => array(
|
340
|
'allowed_values' => array(
|
341
|
array(
|
342
|
'vocabulary' => $this->tag_vocabulary->machine_name,
|
343
|
'parent' => 0,
|
344
|
),
|
345
|
),
|
346
|
),
|
347
|
);
|
348
|
field_create_field($this->tag_field);
|
349
|
|
350
|
// Create an instance of the tag field on one of the content types, and
|
351
|
// configure it to display an autocomplete widget.
|
352
|
$this->tag_instance = array(
|
353
|
'field_name' => 'field_views_testing_tags',
|
354
|
'entity_type' => 'node',
|
355
|
'bundle' => $this->node_type_with_tags->type,
|
356
|
'widget' => array(
|
357
|
'type' => 'taxonomy_autocomplete',
|
358
|
),
|
359
|
'display' => array(
|
360
|
'default' => array(
|
361
|
'type' => 'taxonomy_term_reference_link',
|
362
|
'weight' => 10,
|
363
|
),
|
364
|
'teaser' => array(
|
365
|
'type' => 'taxonomy_term_reference_link',
|
366
|
'weight' => 10,
|
367
|
),
|
368
|
),
|
369
|
);
|
370
|
field_create_instance($this->tag_instance);
|
371
|
}
|
372
|
|
373
|
/**
|
374
|
* Tests the "tagged with" functionality.
|
375
|
*/
|
376
|
function testTaggedWith() {
|
377
|
// In this test we will only create nodes that have an instance of the tag
|
378
|
// field.
|
379
|
$node_add_path = 'node/add/' . $this->node_type_with_tags->type;
|
380
|
|
381
|
// Create three nodes, with different tags.
|
382
|
$tag_field = $this->tag_field['field_name'] . '[' . LANGUAGE_NONE . ']';
|
383
|
$edit = array();
|
384
|
$edit['title'] = $node_tag1_title = $this->randomName();
|
385
|
$edit[$tag_field] = 'tag1';
|
386
|
$this->drupalPost($node_add_path, $edit, t('Save'));
|
387
|
$edit = array();
|
388
|
$edit['title'] = $node_tag1_tag2_title = $this->randomName();
|
389
|
$edit[$tag_field] = 'tag1, tag2';
|
390
|
$this->drupalPost($node_add_path, $edit, t('Save'));
|
391
|
$edit = array();
|
392
|
$edit['title'] = $node_no_tags_title = $this->randomName();
|
393
|
$this->drupalPost($node_add_path, $edit, t('Save'));
|
394
|
|
395
|
// Create a view that filters by taxonomy term "tag1". It should show only
|
396
|
// the two nodes from above that are tagged with "tag1".
|
397
|
$view1 = array();
|
398
|
// First select the node type and update the form so the correct tag field
|
399
|
// is used.
|
400
|
$view1['show[type]'] = $this->node_type_with_tags->type;
|
401
|
$this->drupalPost('admin/structure/views/add', $view1, t('Update "of type" choice'));
|
402
|
// Now resubmit the entire form to the same URL.
|
403
|
$view1['human_name'] = $this->randomName(16);
|
404
|
$view1['name'] = strtolower($this->randomName(16));
|
405
|
$view1['description'] = $this->randomName(16);
|
406
|
$view1['show[tagged_with]'] = 'tag1';
|
407
|
$view1['page[create]'] = 1;
|
408
|
$view1['page[title]'] = $this->randomName(16);
|
409
|
$view1['page[path]'] = $this->randomName(16);
|
410
|
$this->drupalPost(NULL, $view1, t('Save & exit'));
|
411
|
// Visit the page and check that the nodes we expect are present and the
|
412
|
// ones we don't expect are absent.
|
413
|
$this->drupalGet($view1['page[path]']);
|
414
|
$this->assertText($node_tag1_title);
|
415
|
$this->assertText($node_tag1_tag2_title);
|
416
|
$this->assertNoText($node_no_tags_title);
|
417
|
|
418
|
// Create a view that filters by taxonomy term "tag2". It should show only
|
419
|
// the one node from above that is tagged with "tag2".
|
420
|
$view2 = array();
|
421
|
$view2['show[type]'] = $this->node_type_with_tags->type;
|
422
|
$this->drupalPost('admin/structure/views/add', $view2, t('Update "of type" choice'));
|
423
|
$view2['human_name'] = $this->randomName(16);
|
424
|
$view2['name'] = strtolower($this->randomName(16));
|
425
|
$view2['description'] = $this->randomName(16);
|
426
|
$view2['show[tagged_with]'] = 'tag2';
|
427
|
$view2['page[create]'] = 1;
|
428
|
$view2['page[title]'] = $this->randomName(16);
|
429
|
$view2['page[path]'] = $this->randomName(16);
|
430
|
$this->drupalPost(NULL, $view2, t('Save & exit'));
|
431
|
$this->drupalGet($view2['page[path]']);
|
432
|
$this->assertNoText($node_tag1_title);
|
433
|
$this->assertText($node_tag1_tag2_title);
|
434
|
$this->assertNoText($node_no_tags_title);
|
435
|
}
|
436
|
|
437
|
/**
|
438
|
* Test the "tagged with" form element only shows for node types that support it.
|
439
|
*/
|
440
|
function testTaggedWithByNodeType() {
|
441
|
// The tagging field is associated with one of our node types only. So the
|
442
|
// "tagged with" form element on the view wizard should appear on the form
|
443
|
// by default (when the wizard is configured to display all content) and
|
444
|
// also when the node type that has the tagging field is selected, but not
|
445
|
// when the node type that doesn't have the tagging field is selected.
|
446
|
$tags_xpath = '//input[@name="show[tagged_with]"]';
|
447
|
$this->drupalGet('admin/structure/views/add');
|
448
|
$this->assertFieldByXpath($tags_xpath);
|
449
|
$view['show[type]'] = $this->node_type_with_tags->type;
|
450
|
$this->drupalPost('admin/structure/views/add', $view, t('Update "of type" choice'));
|
451
|
$this->assertFieldByXpath($tags_xpath);
|
452
|
$view['show[type]'] = $this->node_type_without_tags->type;
|
453
|
$this->drupalPost(NULL, $view, t('Update "of type" choice'));
|
454
|
$this->assertNoFieldByXpath($tags_xpath);
|
455
|
|
456
|
// If we add an instance of the tagging field to the second node type, the
|
457
|
// "tagged with" form element should not appear for it too.
|
458
|
$instance = $this->tag_instance;
|
459
|
$instance['bundle'] = $this->node_type_without_tags->type;
|
460
|
field_create_instance($instance);
|
461
|
$view['show[type]'] = $this->node_type_with_tags->type;
|
462
|
$this->drupalPost('admin/structure/views/add', $view, t('Update "of type" choice'));
|
463
|
$this->assertFieldByXpath($tags_xpath);
|
464
|
$view['show[type]'] = $this->node_type_without_tags->type;
|
465
|
$this->drupalPost(NULL, $view, t('Update "of type" choice'));
|
466
|
$this->assertFieldByXpath($tags_xpath);
|
467
|
}
|
468
|
|
469
|
}
|
470
|
|
471
|
/**
|
472
|
* Tests the ability of the views wizard to create views with sorts.
|
473
|
*/
|
474
|
class ViewsUIWizardSortingTestCase extends ViewsUIWizardHelper {
|
475
|
|
476
|
/**
|
477
|
*
|
478
|
*/
|
479
|
public static function getInfo() {
|
480
|
return array(
|
481
|
'name' => 'Views UI wizard sorting functionality',
|
482
|
'description' => 'Test the ability of the views wizard to create views with sorts.',
|
483
|
'group' => 'Views UI',
|
484
|
);
|
485
|
}
|
486
|
|
487
|
/**
|
488
|
* Tests the sorting functionality.
|
489
|
*/
|
490
|
function testSorting() {
|
491
|
// Create nodes, each with a different creation time so that we can do a
|
492
|
// meaningful sort.
|
493
|
$node1 = $this->drupalCreateNode(array('created' => REQUEST_TIME));
|
494
|
$node2 = $this->drupalCreateNode(array('created' => REQUEST_TIME + 1));
|
495
|
$node3 = $this->drupalCreateNode(array('created' => REQUEST_TIME + 2));
|
496
|
|
497
|
// Create a view that sorts oldest first.
|
498
|
$view1 = array();
|
499
|
$view1['human_name'] = $this->randomName(16);
|
500
|
$view1['name'] = strtolower($this->randomName(16));
|
501
|
$view1['description'] = $this->randomName(16);
|
502
|
$view1['show[sort]'] = 'created:ASC';
|
503
|
$view1['page[create]'] = 1;
|
504
|
$view1['page[title]'] = $this->randomName(16);
|
505
|
$view1['page[path]'] = $this->randomName(16);
|
506
|
$this->drupalPost('admin/structure/views/add', $view1, t('Save & exit'));
|
507
|
|
508
|
// Make sure the view shows the nodes in the expected order.
|
509
|
$this->assertUrl($view1['page[path]']);
|
510
|
$this->assertText($view1['page[title]']);
|
511
|
$content = $this->drupalGetContent();
|
512
|
$this->assertText($node1->title);
|
513
|
$this->assertText($node2->title);
|
514
|
$this->assertText($node3->title);
|
515
|
$pos1 = strpos($content, $node1->title);
|
516
|
$pos2 = strpos($content, $node2->title);
|
517
|
$pos3 = strpos($content, $node3->title);
|
518
|
$this->assertTrue($pos1 < $pos2 && $pos2 < $pos3, t('The nodes appear in the expected order in a view that sorts by oldest first.'));
|
519
|
|
520
|
// Create a view that sorts newest first.
|
521
|
$view2 = array();
|
522
|
$view2['human_name'] = $this->randomName(16);
|
523
|
$view2['name'] = strtolower($this->randomName(16));
|
524
|
$view2['description'] = $this->randomName(16);
|
525
|
$view2['show[sort]'] = 'created:DESC';
|
526
|
$view2['page[create]'] = 1;
|
527
|
$view2['page[title]'] = $this->randomName(16);
|
528
|
$view2['page[path]'] = $this->randomName(16);
|
529
|
$this->drupalPost('admin/structure/views/add', $view2, t('Save & exit'));
|
530
|
|
531
|
// Make sure the view shows the nodes in the expected order.
|
532
|
$this->assertUrl($view2['page[path]']);
|
533
|
$this->assertText($view2['page[title]']);
|
534
|
$content = $this->drupalGetContent();
|
535
|
$this->assertText($node3->title);
|
536
|
$this->assertText($node2->title);
|
537
|
$this->assertText($node1->title);
|
538
|
$pos3 = strpos($content, $node3->title);
|
539
|
$pos2 = strpos($content, $node2->title);
|
540
|
$pos1 = strpos($content, $node1->title);
|
541
|
$this->assertTrue($pos3 < $pos2 && $pos2 < $pos1, t('The nodes appear in the expected order in a view that sorts by newest first.'));
|
542
|
}
|
543
|
|
544
|
}
|
545
|
|
546
|
/**
|
547
|
* Tests the ability of the wizard to specify the number of items per page.
|
548
|
*/
|
549
|
class ViewsUIWizardItemsPerPageTestCase extends ViewsUIWizardHelper {
|
550
|
|
551
|
/**
|
552
|
*
|
553
|
*/
|
554
|
public static function getInfo() {
|
555
|
return array(
|
556
|
'name' => 'Views UI wizard items per page functionality',
|
557
|
'description' => 'Test the ability of the views wizard to specify the number of items per page.',
|
558
|
'group' => 'Views UI',
|
559
|
);
|
560
|
}
|
561
|
|
562
|
/**
|
563
|
* Tests the number of items per page.
|
564
|
*/
|
565
|
function testItemsPerPage() {
|
566
|
// Create articles, each with a different creation time so that we can do a
|
567
|
// meaningful sort.
|
568
|
$node1 = $this->drupalCreateNode(array('type' => 'article', 'created' => REQUEST_TIME));
|
569
|
$node2 = $this->drupalCreateNode(array('type' => 'article', 'created' => REQUEST_TIME + 1));
|
570
|
$node3 = $this->drupalCreateNode(array('type' => 'article', 'created' => REQUEST_TIME + 2));
|
571
|
$node4 = $this->drupalCreateNode(array('type' => 'article', 'created' => REQUEST_TIME + 3));
|
572
|
$node5 = $this->drupalCreateNode(array('type' => 'article', 'created' => REQUEST_TIME + 4));
|
573
|
|
574
|
// Create a page. This should never appear in the view created below.
|
575
|
$page_node = $this->drupalCreateNode(array('type' => 'page', 'created' => REQUEST_TIME + 2));
|
576
|
|
577
|
// Create a view that sorts newest first, and shows 4 items in the page and
|
578
|
// 3 in the block.
|
579
|
$view = array();
|
580
|
$view['human_name'] = $this->randomName(16);
|
581
|
$view['name'] = strtolower($this->randomName(16));
|
582
|
$view['description'] = $this->randomName(16);
|
583
|
$view['show[wizard_key]'] = 'node';
|
584
|
$view['show[type]'] = 'article';
|
585
|
$view['show[sort]'] = 'created:DESC';
|
586
|
$view['page[create]'] = 1;
|
587
|
$view['page[title]'] = $this->randomName(16);
|
588
|
$view['page[path]'] = $this->randomName(16);
|
589
|
$view['page[items_per_page]'] = 4;
|
590
|
$view['block[create]'] = 1;
|
591
|
$view['block[title]'] = $this->randomName(16);
|
592
|
$view['block[items_per_page]'] = 3;
|
593
|
$this->drupalPost('admin/structure/views/add', $view, t('Save & exit'));
|
594
|
|
595
|
// Make sure the page display shows the nodes we expect, and that they
|
596
|
// appear in the expected order.
|
597
|
$this->assertUrl($view['page[path]']);
|
598
|
$this->assertText($view['page[title]']);
|
599
|
$content = $this->drupalGetContent();
|
600
|
$this->assertText($node5->title);
|
601
|
$this->assertText($node4->title);
|
602
|
$this->assertText($node3->title);
|
603
|
$this->assertText($node2->title);
|
604
|
$this->assertNoText($node1->title);
|
605
|
$this->assertNoText($page_node->title);
|
606
|
$pos5 = strpos($content, $node5->title);
|
607
|
$pos4 = strpos($content, $node4->title);
|
608
|
$pos3 = strpos($content, $node3->title);
|
609
|
$pos2 = strpos($content, $node2->title);
|
610
|
$this->assertTrue($pos5 < $pos4 && $pos4 < $pos3 && $pos3 < $pos2, t('The nodes appear in the expected order in the page display.'));
|
611
|
|
612
|
// Put the block into the first sidebar region, visit a page that displays
|
613
|
// the block, and check that the nodes we expect appear in the correct
|
614
|
// order.
|
615
|
$this->drupalGet('admin/structure/block');
|
616
|
$this->assertText('View: ' . $view['human_name']);
|
617
|
$edit = array();
|
618
|
$edit["blocks[views_{$view['name']}-block][region]"] = 'sidebar_first';
|
619
|
$this->drupalPost('admin/structure/block', $edit, t('Save blocks'));
|
620
|
$this->drupalGet('user');
|
621
|
$content = $this->drupalGetContent();
|
622
|
$this->assertText($node5->title);
|
623
|
$this->assertText($node4->title);
|
624
|
$this->assertText($node3->title);
|
625
|
$this->assertNoText($node2->title);
|
626
|
$this->assertNoText($node1->title);
|
627
|
$this->assertNoText($page_node->title);
|
628
|
$pos5 = strpos($content, $node5->title);
|
629
|
$pos4 = strpos($content, $node4->title);
|
630
|
$pos3 = strpos($content, $node3->title);
|
631
|
$this->assertTrue($pos5 < $pos4 && $pos4 < $pos3, t('The nodes appear in the expected order in the block display.'));
|
632
|
}
|
633
|
|
634
|
}
|
635
|
|
636
|
/**
|
637
|
* Tests the ability of the views wizard to put views in a menu.
|
638
|
*/
|
639
|
class ViewsUIWizardMenuTestCase extends ViewsUIWizardHelper {
|
640
|
|
641
|
/**
|
642
|
*
|
643
|
*/
|
644
|
public static function getInfo() {
|
645
|
return array(
|
646
|
'name' => 'Views UI wizard menu functionality',
|
647
|
'description' => 'Test the ability of the views wizard to put views in a menu.',
|
648
|
'group' => 'Views UI',
|
649
|
);
|
650
|
}
|
651
|
|
652
|
/**
|
653
|
* Tests the menu functionality.
|
654
|
*/
|
655
|
function testMenus() {
|
656
|
// Create a view with a page display and a menu link in the Main Menu.
|
657
|
$view = array();
|
658
|
$view['human_name'] = $this->randomName(16);
|
659
|
$view['name'] = strtolower($this->randomName(16));
|
660
|
$view['description'] = $this->randomName(16);
|
661
|
$view['page[create]'] = 1;
|
662
|
$view['page[title]'] = $this->randomName(16);
|
663
|
$view['page[path]'] = $this->randomName(16);
|
664
|
$view['page[link]'] = 1;
|
665
|
$view['page[link_properties][menu_name]'] = 'main-menu';
|
666
|
$view['page[link_properties][title]'] = $this->randomName(16);
|
667
|
$this->drupalPost('admin/structure/views/add', $view, t('Save & exit'));
|
668
|
|
669
|
// Make sure there is a link to the view from the front page (where we
|
670
|
// expect the main menu to display).
|
671
|
$this->drupalGet('');
|
672
|
$this->assertLink($view['page[link_properties][title]']);
|
673
|
$this->assertLinkByHref(url($view['page[path]']));
|
674
|
|
675
|
// Make sure the link is associated with the main menu.
|
676
|
$links = menu_load_links('main-menu');
|
677
|
$found = FALSE;
|
678
|
foreach ($links as $link) {
|
679
|
if ($link['link_path'] == $view['page[path]']) {
|
680
|
$found = TRUE;
|
681
|
break;
|
682
|
}
|
683
|
}
|
684
|
$this->assertTrue($found, t('Found a link to %path in the main menu', array('%path' => $view['page[path]'])));
|
685
|
}
|
686
|
|
687
|
}
|
688
|
|
689
|
/**
|
690
|
* Tests the ability of the wizard to create views with a jump menu style.
|
691
|
*/
|
692
|
class ViewsUIWizardJumpMenuTestCase extends ViewsUIWizardHelper {
|
693
|
|
694
|
/**
|
695
|
*
|
696
|
*/
|
697
|
public static function getInfo() {
|
698
|
return array(
|
699
|
'name' => 'Views UI wizard jump menu functionality',
|
700
|
'description' => 'Test the ability of the views wizard to create views with a jump menu style plugin.',
|
701
|
'group' => 'Views UI',
|
702
|
);
|
703
|
}
|
704
|
|
705
|
/**
|
706
|
* Tests the jump menu style plugin.
|
707
|
*/
|
708
|
function testJumpMenus() {
|
709
|
// We'll run this test for several different base tables that appear in the
|
710
|
// wizard.
|
711
|
$base_table_methods = array(
|
712
|
'node' => 'createNodeAndGetPath',
|
713
|
'users' => 'createUserAndGetPath',
|
714
|
'comment' => 'createCommentAndGetPath',
|
715
|
'taxonomy_term' => 'createTaxonomyTermAndGetPath',
|
716
|
'file_managed' => 'createFileAndGetPath',
|
717
|
'node_revision' => 'createNodeRevisionAndGetPath',
|
718
|
);
|
719
|
|
720
|
foreach ($base_table_methods as $base_table => $method) {
|
721
|
// For each base table, find the path that we expect the jump menu to
|
722
|
// redirect us to.
|
723
|
$path_info = $this->{$method}();
|
724
|
if (is_array($path_info)) {
|
725
|
$path = $path_info['path'];
|
726
|
$options = isset($path_info['options']) ? $path_info['options'] : array();
|
727
|
}
|
728
|
else {
|
729
|
$path = $path_info;
|
730
|
$options = array();
|
731
|
}
|
732
|
|
733
|
// Create a page view for the specified base table that uses the jump
|
734
|
// menu style plugin.
|
735
|
$view = array();
|
736
|
$view['human_name'] = $this->randomName(16);
|
737
|
$view['name'] = strtolower($this->randomName(16));
|
738
|
$view['description'] = $this->randomName(16);
|
739
|
$view['show[wizard_key]'] = $base_table;
|
740
|
$view['page[create]'] = 1;
|
741
|
$view['page[title]'] = $this->randomName(16);
|
742
|
$view['page[path]'] = $this->randomName(16);
|
743
|
$view['page[style][style_plugin]'] = 'jump_menu';
|
744
|
$view['page[style][row_plugin]'] = 'fields';
|
745
|
$this->drupalPost('admin/structure/views/add', $view, t('Save & exit'));
|
746
|
|
747
|
// Submit the jump menu form, and check that we are redirected to the
|
748
|
// expected URL.
|
749
|
$edit = array();
|
750
|
$edit['jump'] = url($path, $options);
|
751
|
|
752
|
// The urls are built with :: to be able to have a unique path all the time,
|
753
|
// so try to find out the real path of $edit.
|
754
|
$view_object = views_get_view($view['name']);
|
755
|
$view_object->preview('page');
|
756
|
$form = $view_object->style_plugin->render();
|
757
|
$jump_options = $form['jump']['#options'];
|
758
|
foreach ($jump_options as $key => $title) {
|
759
|
if (strpos($key, $edit['jump']) !== FALSE) {
|
760
|
$edit['jump'] = $key;
|
761
|
}
|
762
|
}
|
763
|
|
764
|
$this->drupalPost($view['page[path]'], $edit, t('Go'));
|
765
|
$this->assertResponse(200);
|
766
|
$this->assertUrl($path, $options);
|
767
|
}
|
768
|
}
|
769
|
|
770
|
/**
|
771
|
* Helper function to create a node and return its expected path.
|
772
|
*/
|
773
|
function createNodeAndGetPath() {
|
774
|
$node = $this->drupalCreateNode();
|
775
|
return entity_uri('node', $node);
|
776
|
}
|
777
|
|
778
|
/**
|
779
|
* Helper function to create a user and return its expected path.
|
780
|
*/
|
781
|
function createUserAndGetPath() {
|
782
|
$account = $this->drupalCreateUser();
|
783
|
return entity_uri('user', $account);
|
784
|
}
|
785
|
|
786
|
/**
|
787
|
* Helper function to create a comment and return its expected path.
|
788
|
*/
|
789
|
function createCommentAndGetPath() {
|
790
|
$node = $this->drupalCreateNode();
|
791
|
$comment = (object) array(
|
792
|
'cid' => NULL,
|
793
|
'nid' => $node->nid,
|
794
|
'pid' => 0,
|
795
|
'uid' => 0,
|
796
|
'status' => COMMENT_PUBLISHED,
|
797
|
'subject' => $this->randomName(),
|
798
|
'language' => LANGUAGE_NONE,
|
799
|
'comment_body' => array(LANGUAGE_NONE => array($this->randomName())),
|
800
|
);
|
801
|
comment_save($comment);
|
802
|
return entity_uri('comment', $comment);
|
803
|
}
|
804
|
|
805
|
/**
|
806
|
* Helper function to create a taxonomy term and return its expected path.
|
807
|
*/
|
808
|
function createTaxonomyTermAndGetPath() {
|
809
|
$vocabulary = new stdClass();
|
810
|
$vocabulary->name = $this->randomName();
|
811
|
$vocabulary->machine_name = drupal_strtolower($this->randomName());
|
812
|
taxonomy_vocabulary_save($vocabulary);
|
813
|
|
814
|
$term = new stdClass();
|
815
|
$term->name = $this->randomName();
|
816
|
$term->vid = $vocabulary->vid;
|
817
|
taxonomy_term_save($term);
|
818
|
|
819
|
return entity_uri('taxonomy_term', $term);
|
820
|
}
|
821
|
|
822
|
/**
|
823
|
* Helper function to create a file and return its expected path.
|
824
|
*/
|
825
|
function createFileAndGetPath() {
|
826
|
$file = (object) array(
|
827
|
'uid' => 1,
|
828
|
'filename' => 'views-ui-jump-menu-test.txt',
|
829
|
'uri' => 'public://views-ui-jump-menu-test.txt',
|
830
|
'filemime' => 'text/plain',
|
831
|
'timestamp' => 1,
|
832
|
'status' => FILE_STATUS_PERMANENT,
|
833
|
);
|
834
|
file_put_contents($file->uri, 'test content');
|
835
|
$file = file_save($file);
|
836
|
return file_create_url($file->uri);
|
837
|
}
|
838
|
|
839
|
/**
|
840
|
* Helper function to create a node revision and return its expected path.
|
841
|
*/
|
842
|
function createNodeRevisionAndGetPath() {
|
843
|
// The node needs at least two revisions in order for Drupal to allow
|
844
|
// access to the revision path.
|
845
|
$settings = array('revision' => TRUE);
|
846
|
$node = $this->drupalCreateNode($settings);
|
847
|
$node->vid = NULL;
|
848
|
node_save($node);
|
849
|
return 'node/' . $node->nid . '/revisions/' . $node->vid . '/view';
|
850
|
}
|
851
|
|
852
|
}
|
853
|
|
854
|
/**
|
855
|
* Tests that displays can be correctly overridden via the user interface.
|
856
|
*/
|
857
|
class ViewsUIWizardOverrideDisplaysTestCase extends ViewsUIWizardHelper {
|
858
|
|
859
|
/**
|
860
|
*
|
861
|
*/
|
862
|
public static function getInfo() {
|
863
|
return array(
|
864
|
'name' => 'Views UI overridden displays',
|
865
|
'description' => 'Test that displays can be correctly overridden via the user interface.',
|
866
|
'group' => 'Views UI',
|
867
|
);
|
868
|
}
|
869
|
|
870
|
/**
|
871
|
* Tests that displays can be overridden via the UI.
|
872
|
*/
|
873
|
function testOverrideDisplays() {
|
874
|
// Create a basic view that shows all content, with a page and a block
|
875
|
// display.
|
876
|
$view['human_name'] = $this->randomName(16);
|
877
|
$view['name'] = strtolower($this->randomName(16));
|
878
|
$view['page[create]'] = 1;
|
879
|
$view['page[path]'] = $this->randomName(16);
|
880
|
$view['block[create]'] = 1;
|
881
|
$view_path = $view['page[path]'];
|
882
|
$this->drupalPost('admin/structure/views/add', $view, t('Save & exit'));
|
883
|
|
884
|
// Configure its title. Since the page and block both started off with the
|
885
|
// same (empty) title in the views wizard, we expect the wizard to have set
|
886
|
// things up so that they both inherit from the default display, and we
|
887
|
// therefore only need to change that to have it take effect for both.
|
888
|
$edit = array();
|
889
|
$edit['title'] = $original_title = $this->randomName(16);
|
890
|
$edit['override[dropdown]'] = 'default';
|
891
|
$this->drupalPost("admin/structure/views/nojs/display/{$view['name']}/page/title", $edit, t('Apply'));
|
892
|
$this->drupalPost("admin/structure/views/view/{$view['name']}/edit/page", array(), t('Save'));
|
893
|
|
894
|
// Put the block into the first sidebar region, and make sure it will not
|
895
|
// display on the view's page display (since we will be searching for the
|
896
|
// presence/absence of the view's title in both the page and the block).
|
897
|
$this->drupalGet('admin/structure/block');
|
898
|
$edit = array();
|
899
|
$edit["blocks[views_{$view['name']}-block][region]"] = 'sidebar_first';
|
900
|
$this->drupalPost('admin/structure/block', $edit, t('Save blocks'));
|
901
|
$edit = array();
|
902
|
$edit['visibility'] = BLOCK_VISIBILITY_NOTLISTED;
|
903
|
$edit['pages'] = $view_path;
|
904
|
$this->drupalPost("admin/structure/block/manage/views/{$view['name']}-block/configure", $edit, t('Save block'));
|
905
|
|
906
|
// Add a node that will appear in the view, so that the block will actually
|
907
|
// be displayed.
|
908
|
$this->drupalCreateNode();
|
909
|
|
910
|
// Make sure the title appears in both the page and the block.
|
911
|
$this->drupalGet($view_path);
|
912
|
$this->assertText($original_title);
|
913
|
$this->drupalGet('');
|
914
|
$this->assertText($original_title);
|
915
|
|
916
|
// Change the title for the page display only, and make sure that is the
|
917
|
// only one that is changed.
|
918
|
$edit = array();
|
919
|
$edit['title'] = $new_title = $this->randomName(16);
|
920
|
$edit['override[dropdown]'] = 'page';
|
921
|
$this->drupalPost("admin/structure/views/nojs/display/{$view['name']}/page/title", $edit, t('Apply'));
|
922
|
$this->drupalPost("admin/structure/views/view/{$view['name']}/edit/page", array(), t('Save'));
|
923
|
$this->drupalGet($view_path);
|
924
|
$this->assertText($new_title);
|
925
|
$this->assertNoText($original_title);
|
926
|
$this->drupalGet('');
|
927
|
$this->assertText($original_title);
|
928
|
$this->assertNoText($new_title);
|
929
|
}
|
930
|
|
931
|
/**
|
932
|
* Tests that the wizard correctly sets up default and overridden displays.
|
933
|
*/
|
934
|
function testWizardMixedDefaultOverriddenDisplays() {
|
935
|
// Create a basic view with a page, block, and feed. Give the page and feed
|
936
|
// identical titles, but give the block a different one, so we expect the
|
937
|
// page and feed to inherit their titles from the default display, but the
|
938
|
// block to override it.
|
939
|
$view['human_name'] = $this->randomName(16);
|
940
|
$view['name'] = strtolower($this->randomName(16));
|
941
|
$view['page[create]'] = 1;
|
942
|
$view['page[title]'] = $this->randomName(16);
|
943
|
$view['page[path]'] = $this->randomName(16);
|
944
|
$view['page[feed]'] = 1;
|
945
|
$view['page[feed_properties][path]'] = $this->randomName(16);
|
946
|
$view['block[create]'] = 1;
|
947
|
$view['block[title]'] = $this->randomName(16);
|
948
|
$this->drupalPost('admin/structure/views/add', $view, t('Save & exit'));
|
949
|
|
950
|
// Put the block into the first sidebar region, and make sure it will not
|
951
|
// display on the view's page display (since we will be searching for the
|
952
|
// presence/absence of the view's title in both the page and the block).
|
953
|
$this->drupalGet('admin/structure/block');
|
954
|
$edit = array();
|
955
|
$edit["blocks[views_{$view['name']}-block][region]"] = 'sidebar_first';
|
956
|
$this->drupalPost('admin/structure/block', $edit, t('Save blocks'));
|
957
|
$edit = array();
|
958
|
$edit['visibility'] = BLOCK_VISIBILITY_NOTLISTED;
|
959
|
$edit['pages'] = $view['page[path]'];
|
960
|
$this->drupalPost("admin/structure/block/manage/views/{$view['name']}-block/configure", $edit, t('Save block'));
|
961
|
|
962
|
// Add a node that will appear in the view, so that the block will actually
|
963
|
// be displayed.
|
964
|
$this->drupalCreateNode();
|
965
|
|
966
|
// Make sure that the feed, page and block all start off with the correct
|
967
|
// titles.
|
968
|
$this->drupalGet($view['page[path]']);
|
969
|
$this->assertText($view['page[title]']);
|
970
|
$this->assertNoText($view['block[title]']);
|
971
|
$this->drupalGet($view['page[feed_properties][path]']);
|
972
|
$this->assertText($view['page[title]']);
|
973
|
$this->assertNoText($view['block[title]']);
|
974
|
$this->drupalGet('');
|
975
|
$this->assertText($view['block[title]']);
|
976
|
$this->assertNoText($view['page[title]']);
|
977
|
|
978
|
// Edit the page and change the title. This should automatically change
|
979
|
// the feed's title also, but not the block.
|
980
|
$edit = array();
|
981
|
$edit['title'] = $new_default_title = $this->randomName(16);
|
982
|
$this->drupalPost("admin/structure/views/nojs/display/{$view['name']}/page/title", $edit, t('Apply'));
|
983
|
$this->drupalPost("admin/structure/views/view/{$view['name']}/edit/page", array(), t('Save'));
|
984
|
$this->drupalGet($view['page[path]']);
|
985
|
$this->assertText($new_default_title);
|
986
|
$this->assertNoText($view['page[title]']);
|
987
|
$this->assertNoText($view['block[title]']);
|
988
|
$this->drupalGet($view['page[feed_properties][path]']);
|
989
|
$this->assertText($new_default_title);
|
990
|
$this->assertNoText($view['page[title]']);
|
991
|
$this->assertNoText($view['block[title]']);
|
992
|
$this->drupalGet('');
|
993
|
$this->assertText($view['block[title]']);
|
994
|
$this->assertNoText($new_default_title);
|
995
|
$this->assertNoText($view['page[title]']);
|
996
|
|
997
|
// Edit the block and change the title. This should automatically change
|
998
|
// the block title only, and leave the defaults alone.
|
999
|
$edit = array();
|
1000
|
$edit['title'] = $new_block_title = $this->randomName(16);
|
1001
|
$this->drupalPost("admin/structure/views/nojs/display/{$view['name']}/block/title", $edit, t('Apply'));
|
1002
|
$this->drupalPost("admin/structure/views/view/{$view['name']}/edit/block", array(), t('Save'));
|
1003
|
$this->drupalGet($view['page[path]']);
|
1004
|
$this->assertText($new_default_title);
|
1005
|
$this->assertNoText($new_block_title);
|
1006
|
$this->drupalGet($view['page[feed_properties][path]']);
|
1007
|
$this->assertText($new_default_title);
|
1008
|
$this->assertNoText($new_block_title);
|
1009
|
$this->drupalGet('');
|
1010
|
$this->assertText($new_block_title);
|
1011
|
$this->assertNoText($view['block[title]']);
|
1012
|
}
|
1013
|
|
1014
|
/**
|
1015
|
* Tests that the revert to all displays select-option works as expected.
|
1016
|
*/
|
1017
|
function testRevertAllDisplays() {
|
1018
|
// Create a basic view with a page, block. Because there is both a title on
|
1019
|
// page and block we expect the title on the block be overriden.
|
1020
|
$view['human_name'] = $this->randomName(16);
|
1021
|
$view['name'] = strtolower($this->randomName(16));
|
1022
|
$view['page[create]'] = 1;
|
1023
|
$view['page[title]'] = $this->randomName(16);
|
1024
|
$view['page[path]'] = $this->randomName(16);
|
1025
|
$view['block[create]'] = 1;
|
1026
|
$view['block[title]'] = $this->randomName(16);
|
1027
|
$this->drupalPost('admin/structure/views/add', $view, t('Continue & edit'));
|
1028
|
|
1029
|
// Revert the title of the block back to the default ones, but submit some
|
1030
|
// new values to be sure that the new value is not stored.
|
1031
|
$edit = array();
|
1032
|
$edit['title'] = $new_block_title = $this->randomName();
|
1033
|
$edit['override[dropdown]'] = 'default_revert';
|
1034
|
|
1035
|
$this->drupalPost("admin/structure/views/nojs/display/{$view['name']}/block/title", $edit, t('Apply'));
|
1036
|
$this->drupalPost("admin/structure/views/view/{$view['name']}/edit/block", array(), t('Save'));
|
1037
|
$this->assertText($view['page[title]']);
|
1038
|
}
|
1039
|
|
1040
|
}
|