Skip to content

Commit

Permalink
Fix for unit tests that break in the new year
Browse files Browse the repository at this point in the history
Previously, the unit tests failed when date('Y') returned a new value.

A new, undocumented param is added to html_select_date to allow the
year to be mocked. This function is deprecated and will be removed in a
future version of Brainy.
  • Loading branch information
Matt Basta committed Jan 15, 2015
1 parent 05329ef commit 57b711a
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 40 deletions.
8 changes: 7 additions & 1 deletion src/Brainy/plugins/function.html_select_date.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ function smarty_function_html_select_date($params, $template) {
'field_separator' => "\n",
'option_separator' => "\n",
'time' => null,
'rel_time' => null,
'extra_attrs' => '',
'all_id' => null,
'day_id' => null,
Expand All @@ -117,9 +118,10 @@ function smarty_function_html_select_date($params, $template) {

foreach ($params as $_key => $_value) {
switch ($_key) {
case 'rel_time':
case 'time':
if (!is_array($_value) && $_value !== null) {
$options['time'] = smarty_make_timestamp($_value);
$options[$_key] = smarty_make_timestamp($_value);
}
break;

Expand Down Expand Up @@ -178,6 +180,10 @@ function smarty_function_html_select_date($params, $template) {
}
}

if (!empty($params['rel_time'])) {
$_current_year = date('Y', $params['rel_time']);
}

$timeData = array(
'_day' => null,
'_month' => null,
Expand Down
Loading

0 comments on commit 57b711a

Please sign in to comment.