1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
* @file
|
4 |
|
|
* Definition of ViewsHandlerArgumentNullTest.
|
5 |
|
|
*/
|
6 |
|
|
|
7 |
|
|
/**
|
8 |
|
|
* Tests the core views_handler_argument_string handler.
|
9 |
|
|
*/
|
10 |
|
|
class ViewsHandlerArgumentStringTest extends ViewsSqlTest {
|
11 |
|
|
public static function getInfo() {
|
12 |
|
|
return array(
|
13 |
|
|
'name' => 'Argument: String',
|
14 |
|
|
'description' => 'Test the core views_handler_argument_string handler.',
|
15 |
|
|
'group' => 'Views Handlers',
|
16 |
|
|
);
|
17 |
|
|
}
|
18 |
|
|
|
19 |
|
|
/**
|
20 |
|
|
* Tests the glossary feature.
|
21 |
|
|
*/
|
22 |
|
|
function testGlossary() {
|
23 |
|
|
// Setup some nodes, one with a, two with b and three with c.
|
24 |
|
|
$counter = 1;
|
25 |
|
|
foreach (array('a', 'b', 'c') as $char) {
|
26 |
|
|
for ($i = 0; $i < $counter; $i++) {
|
27 |
|
|
$edit = array(
|
28 |
|
|
'title' => $char . $this->randomName(),
|
29 |
|
|
);
|
30 |
|
|
$this->drupalCreateNode($edit);
|
31 |
|
|
}
|
32 |
|
|
}
|
33 |
|
|
|
34 |
|
|
$view = $this->viewGlossary();
|
35 |
|
|
$view->init_display();
|
36 |
|
|
$this->executeView($view);
|
37 |
|
|
|
38 |
|
|
$count_field = 'nid';
|
39 |
|
|
foreach ($view->result as &$row) {
|
40 |
|
|
if (strpos($row->node_title, 'a') === 0) {
|
41 |
|
|
$this->assertEqual(1, $row->{$count_field});
|
42 |
|
|
}
|
43 |
|
|
if (strpos($row->node_title, 'b') === 0) {
|
44 |
|
|
$this->assertEqual(2, $row->{$count_field});
|
45 |
|
|
}
|
46 |
|
|
if (strpos($row->node_title, 'c') === 0) {
|
47 |
|
|
$this->assertEqual(3, $row->{$count_field});
|
48 |
|
|
}
|
49 |
|
|
}
|
50 |
|
|
}
|
51 |
|
|
|
52 |
|
|
/**
|
53 |
|
|
* Provide a test view for testGlossary.
|
54 |
|
|
*
|
55 |
|
|
* @see testGlossary
|
56 |
|
|
* @return view
|
57 |
|
|
*/
|
58 |
|
|
function viewGlossary() {
|
59 |
|
|
$view = new view();
|
60 |
|
|
$view->name = 'test_glossary';
|
61 |
|
|
$view->description = '';
|
62 |
|
|
$view->tag = 'default';
|
63 |
|
|
$view->base_table = 'node';
|
64 |
|
|
$view->human_name = 'test_glossary';
|
65 |
|
|
$view->core = 7;
|
66 |
|
|
$view->api_version = '3.0';
|
67 |
|
|
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
|
68 |
|
|
|
69 |
|
|
/* Display: Master */
|
70 |
|
|
$handler = $view->new_display('default', 'Master', 'default');
|
71 |
|
|
$handler->display->display_options['access']['type'] = 'perm';
|
72 |
|
|
$handler->display->display_options['cache']['type'] = 'none';
|
73 |
|
|
$handler->display->display_options['query']['type'] = 'views_query';
|
74 |
|
|
$handler->display->display_options['exposed_form']['type'] = 'basic';
|
75 |
|
|
$handler->display->display_options['pager']['type'] = 'full';
|
76 |
|
|
$handler->display->display_options['style_plugin'] = 'default';
|
77 |
|
|
$handler->display->display_options['row_plugin'] = 'fields';
|
78 |
|
|
/* Field: Content: Title */
|
79 |
|
|
$handler->display->display_options['fields']['title']['id'] = 'title';
|
80 |
|
|
$handler->display->display_options['fields']['title']['table'] = 'node';
|
81 |
|
|
$handler->display->display_options['fields']['title']['field'] = 'title';
|
82 |
|
|
$handler->display->display_options['fields']['title']['label'] = '';
|
83 |
|
|
/* Contextual filter: Content: Title */
|
84 |
|
|
$handler->display->display_options['arguments']['title']['id'] = 'title';
|
85 |
|
|
$handler->display->display_options['arguments']['title']['table'] = 'node';
|
86 |
|
|
$handler->display->display_options['arguments']['title']['field'] = 'title';
|
87 |
|
|
$handler->display->display_options['arguments']['title']['default_argument_type'] = 'fixed';
|
88 |
|
|
$handler->display->display_options['arguments']['title']['summary']['number_of_records'] = '0';
|
89 |
|
|
$handler->display->display_options['arguments']['title']['summary']['format'] = 'default_summary';
|
90 |
|
|
$handler->display->display_options['arguments']['title']['summary_options']['items_per_page'] = '25';
|
91 |
|
|
$handler->display->display_options['arguments']['title']['glossary'] = TRUE;
|
92 |
|
|
$handler->display->display_options['arguments']['title']['limit'] = '1';
|
93 |
|
|
|
94 |
|
|
return $view;
|
95 |
|
|
}
|
96 |
|
|
} |