1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Definition of ViewsHandlerFilterCounterTest.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* Tests the views_handler_field_counter handler.
|
10
|
*/
|
11
|
class ViewsHandlerFilterCounterTest extends ViewsSqlTest {
|
12
|
public static function getInfo() {
|
13
|
return array(
|
14
|
'name' => 'Field: Counter',
|
15
|
'description' => 'Tests the views_handler_field_counter handler.',
|
16
|
'group' => 'Views Handlers',
|
17
|
);
|
18
|
}
|
19
|
|
20
|
function testSimple() {
|
21
|
$view = $this->getBasicView();
|
22
|
$view->display['default']->handler->override_option('fields', array(
|
23
|
'counter' => array(
|
24
|
'id' => 'counter',
|
25
|
'table' => 'views',
|
26
|
'field' => 'counter',
|
27
|
'relationship' => 'none',
|
28
|
),
|
29
|
'name' => array(
|
30
|
'id' => 'name',
|
31
|
'table' => 'views_test',
|
32
|
'field' => 'name',
|
33
|
'relationship' => 'none',
|
34
|
),
|
35
|
));
|
36
|
$view->preview();
|
37
|
|
38
|
$this->assertEqual(1, $view->style_plugin->rendered_fields[0]['counter']);
|
39
|
$this->assertEqual(2, $view->style_plugin->rendered_fields[1]['counter']);
|
40
|
$this->assertEqual(3, $view->style_plugin->rendered_fields[2]['counter']);
|
41
|
$view->destroy();
|
42
|
|
43
|
$view = $this->getBasicView();
|
44
|
$rand_start = rand(5, 10);
|
45
|
$view->display['default']->handler->override_option('fields', array(
|
46
|
'counter' => array(
|
47
|
'id' => 'counter',
|
48
|
'table' => 'views',
|
49
|
'field' => 'counter',
|
50
|
'relationship' => 'none',
|
51
|
'counter_start' => $rand_start,
|
52
|
),
|
53
|
'name' => array(
|
54
|
'id' => 'name',
|
55
|
'table' => 'views_test',
|
56
|
'field' => 'name',
|
57
|
'relationship' => 'none',
|
58
|
),
|
59
|
));
|
60
|
$view->preview();
|
61
|
|
62
|
$this->assertEqual(0 + $rand_start, $view->style_plugin->rendered_fields[0]['counter']);
|
63
|
$this->assertEqual(1 + $rand_start, $view->style_plugin->rendered_fields[1]['counter']);
|
64
|
$this->assertEqual(2 + $rand_start, $view->style_plugin->rendered_fields[2]['counter']);
|
65
|
}
|
66
|
|
67
|
// @todo Write tests for pager.
|
68
|
function testPager() {
|
69
|
}
|
70
|
|
71
|
}
|