add test to prev commit
[project/views.git] / tests / handlers / views_handler_field_boolean.test
CommitLineData
4f79c7e7 1<?php
4f79c7e7 2
6e5e1c2b 3class ViewsHandlerFieldBooleanTest extends ViewsSqlTest {
4f79c7e7
DW
4 public static function getInfo() {
5 return array(
6 'name' => 'Field: Boolean',
7 'description' => 'Test the core views_handler_field_boolean handler.',
8 'group' => 'Views Handlers',
9 );
10 }
11
12 function dataSet() {
13 // Use default dataset but remove the age from john and paul
14 $data = parent::dataSet();
15 $data[0]['age'] = 0;
16 $data[3]['age'] = 0;
17 return $data;
18 }
a2859ed1 19
4f79c7e7
DW
20 function viewsData() {
21 $data = parent::viewsData();
22 $data['views_test']['age']['field']['handler'] = 'views_handler_field_boolean';
23 return $data;
24 }
25
26 public function testFieldBoolean() {
27 $view = $this->getBasicView();
28
29 $view->display['default']->handler->override_option('fields', array(
30 'age' => array(
31 'id' => 'age',
32 'table' => 'views_test',
33 'field' => 'age',
34 'relationship' => 'none',
35 ),
36 ));
37
38 $this->executeView($view);
39
40 // This is john, which has no age, there are no custom formats defined, yet.
e99616e2
DW
41 $this->assertEqual(t('No'), $view->field['age']->advanced_render($view->result[0]));
42 $this->assertEqual(t('Yes'), $view->field['age']->advanced_render($view->result[1]));
a2859ed1 43
4f79c7e7
DW
44 // Reverse the output.
45 $view->field['age']->options['not'] = TRUE;
e99616e2
DW
46 $this->assertEqual(t('Yes'), $view->field['age']->advanced_render($view->result[0]));
47 $this->assertEqual(t('No'), $view->field['age']->advanced_render($view->result[1]));
a2859ed1 48
4f79c7e7 49 unset($view->field['age']->options['not']);
a2859ed1 50
4f79c7e7
DW
51 // Use another output format.
52 $view->field['age']->options['type'] = 'true-false';
e99616e2
DW
53 $this->assertEqual(t('False'), $view->field['age']->advanced_render($view->result[0]));
54 $this->assertEqual(t('True'), $view->field['age']->advanced_render($view->result[1]));
a2859ed1 55
596c2f21
DW
56 // test awesome unicode.
57 $view->field['age']->options['type'] = 'unicode-yes-no';
58 $this->assertEqual('✖', $view->field['age']->advanced_render($view->result[0]));
59 $this->assertEqual('✔', $view->field['age']->advanced_render($view->result[1]));
60
4f79c7e7
DW
61 // Set a custom output format.
62 $view->field['age']->formats['test'] = array(t('Test-True'), t('Test-False'));
63 $view->field['age']->options['type'] = 'test';
e99616e2
DW
64 $this->assertEqual(t('Test-False'), $view->field['age']->advanced_render($view->result[0]));
65 $this->assertEqual(t('Test-True'), $view->field['age']->advanced_render($view->result[1]));
a2859ed1 66
4f79c7e7
DW
67 }
68}