views_handler_field_math.test
1.04 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
<?php
/**
* @file
* Definition of ViewsHandlerFieldMath.
*/
/**
* Tests the core views_handler_field_math handler.
*/
class ViewsHandlerFieldMath extends ViewsSqlTest {
public static function getInfo() {
return array(
'name' => 'Field: Math',
'description' => 'Test the core views_handler_field_math handler.',
'group' => 'Views Handlers',
);
}
function viewsData() {
$data = parent::viewsData();
return $data;
}
public function testFieldCustom() {
$view = $this->getBasicView();
// Alter the text of the field to a random string.
$rand1 = rand(0, 100);
$rand2 = rand(0, 100);
$view->display['default']->handler->override_option('fields', array(
'expression' => array(
'id' => 'expression',
'table' => 'views',
'field' => 'expression',
'relationship' => 'none',
'expression' => $rand1 . ' + ' . $rand2,
),
));
$this->executeView($view);
$this->assertEqual($rand1 + $rand2, $view->style_plugin->get_field(0, 'expression'));
}
}