Révision 5d12d676
Ajouté par Assos Assos il y a environ 6 ans
drupal7/sites/all/modules/views/tests/handlers/views_handler_field_date.test | ||
---|---|---|
9 | 9 |
* Tests the core views_handler_field_date handler. |
10 | 10 |
*/ |
11 | 11 |
class ViewsHandlerFieldDateTest extends ViewsSqlTest { |
12 |
|
|
13 |
/** |
|
14 |
* |
|
15 |
*/ |
|
12 | 16 |
public static function getInfo() { |
13 | 17 |
return array( |
14 | 18 |
'name' => 'Field: Date', |
... | ... | |
17 | 21 |
); |
18 | 22 |
} |
19 | 23 |
|
24 |
/** |
|
25 |
* |
|
26 |
*/ |
|
20 | 27 |
function viewsData() { |
21 | 28 |
$data = parent::viewsData(); |
22 | 29 |
$data['views_test']['created']['field']['handler'] = 'views_handler_field_date'; |
23 | 30 |
return $data; |
24 | 31 |
} |
25 | 32 |
|
33 |
/** |
|
34 |
* |
|
35 |
*/ |
|
26 | 36 |
public function testFieldDate() { |
27 | 37 |
$view = $this->getBasicView(); |
28 | 38 |
|
... | ... | |
32 | 42 |
'table' => 'views_test', |
33 | 43 |
'field' => 'created', |
34 | 44 |
'relationship' => 'none', |
35 |
// c is iso 8601 date format @see http://php.net/manual/en/function.date.php |
|
45 |
// c is iso 8601 date format. |
|
46 |
// @see http://php.net/manual/en/function.date.php |
|
36 | 47 |
'custom_date_format' => 'c', |
37 | 48 |
'second_date_format' => 'custom', |
38 | 49 |
'second_date_format_custom' => 'c', |
... | ... | |
62 | 73 |
$intervals = array( |
63 | 74 |
'raw time ago' => format_interval(REQUEST_TIME - $time, 2), |
64 | 75 |
'time ago' => t('%time ago', array('%time' => format_interval(REQUEST_TIME - $time, 2))), |
65 |
// TODO write tests for them |
|
66 |
// 'raw time span' => format_interval(REQUEST_TIME - $time, 2), |
|
67 |
// 'time span' => t('%time hence', array('%time' => format_interval(REQUEST_TIME - $time, 2))), |
|
76 |
// @todo write tests for them |
|
77 |
// 'raw time span' => format_interval(REQUEST_TIME - $time, 2), |
|
78 |
// 'time span' => t('%time hence', |
|
79 |
// array('%time' => format_interval(REQUEST_TIME - $time, 2))), |
|
68 | 80 |
); |
69 | 81 |
$this->assertRenderedDatesEqual($view, $intervals); |
70 | 82 |
} |
71 | 83 |
|
84 |
/** |
|
85 |
* |
|
86 |
*/ |
|
72 | 87 |
protected function assertRenderedDatesEqual($view, $map, $timezone = NULL) { |
73 | 88 |
foreach ($map as $date_format => $expected_result) { |
74 | 89 |
$check_result_number = 0; |
... | ... | |
114 | 129 |
|
115 | 130 |
return $data; |
116 | 131 |
} |
132 |
|
|
117 | 133 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules