-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathaltpager.test
More file actions
134 lines (104 loc) · 3.02 KB
/
altpager.test
File metadata and controls
134 lines (104 loc) · 3.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php
/**
* @file
* Tests for altpager.module.
*/
/**
* Test the module functions.
*/
class AltpagerTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => 'Functional testing',
'description' => 'Test functions altpager.module.',
'group' => 'Altpager',
);
}
public function setUp() {
parent::setUp(array('altpager'));
}
/**
* The main test module.
*/
public function testAltpager() {
$query = db_select('node', 'n')->extend('AltPager');
$nids_count = $query
->fields('n', array('nid'))
->orderBy('created', 'DESC')
->execute()
->rowCount();
$default_items = altpager_default_items();
$min_count_items = key($default_items);
$this->assertTrue($nids_count <= $min_count_items);
next($default_items);
$min_count_items = key($default_items);
for ($i = 0; $i <= $min_count_items; ++$i) {
$this->drupalCreateNode();
}
altpager_apcount($min_count_items);
$query = db_select('node', 'n')->extend('AltPager');
$nids_count = $query
->fields('n', array('nid'))
->orderBy('created', 'DESC')
->execute()
->rowCount();
$this->assertEqual($min_count_items, $nids_count);
}
/**
* Testing the standard list of the quantity limitations output nodes.
*/
public function testAltpagerDefaultItems() {
$max_items = 1000;
altpager_count_all_items($max_items);
$items = altpager_default_items();
$this->assertEqual(end($items), $max_items);
}
/**
* Testing count items viewed in current page.
*/
public function testAltpagerCountItemsViewed() {
altpager_count_all_items(1000);
$count = altpager_count_items_viewed();
$default_items = altpager_default_items();
next($default_items);
$min_count_items = key($default_items);
$this->assertEqual($min_count_items, $count);
// No such values, the minimum value is selected.
altpager_apcount(25);
$count = altpager_count_items_viewed();
// The first value in the list.
prev($default_items);
$min_count_items = key($default_items);
$this->assertEqual($min_count_items, $count);
// Change the value "apcount".
altpager_apcount(10);
$count = altpager_count_items_viewed();
$this->assertEqual($min_count_items, $count);
}
/**
* Testing function get count node viewed.
*/
public function testAltpagerApcount() {
altpager_apcount(25);
$this->assertEqual(altpager_apcount(), 25);
}
/**
* Testing function altpager_items_elements().
*/
public function testAltpagerItemsElements() {
altpager_items_elements(array(
1 => 1,
2 => 2,
5 => 5,
));
$this->drupalCreateNode();
$default_items = altpager_default_items();
$query = db_select('node', 'n')->extend('AltPager');
$nids_count = $query
->fields('n', array('nid'))
->execute()
->rowCount();
$min_count_items = key($default_items);
$this->assertEqual($min_count_items, $nids_count);
}
}