Merge pull request #252 from marc1706/ticket/248
[ticket/248] Be less restrictive on date & time strings
This commit is contained in:
@@ -28,17 +28,10 @@
|
||||
</dl>
|
||||
<dl>
|
||||
<dt>
|
||||
<label for="event_start_day">{L_ACP_PORTAL_EVENT_START_DAY}:</label><br />
|
||||
<span>{L_ACP_PORTAL_EVENT_START_DAY_EXP}</span>
|
||||
<label for="event_start_date">{L_ACP_PORTAL_EVENT_START_DATE}:</label><br />
|
||||
<span>{L_ACP_PORTAL_EVENT_START_DATE_EXP}</span>
|
||||
</dt>
|
||||
<dd><input name="event_start_day" type="text" id="event_start_day" value="{EVENT_START_DAY}" maxlength="255" /></dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt>
|
||||
<label for="event_start_time">{L_ACP_PORTAL_EVENT_START_TIME}:</label><br />
|
||||
<span>{L_ACP_PORTAL_EVENT_START_TIME_EXP}</span>
|
||||
</dt>
|
||||
<dd><input name="event_start_time" type="text" id="event_start_time" value="{EVENT_START_TIME}" maxlength="255" /></dd>
|
||||
<dd><input name="event_start_date" type="text" id="event_start_date" value="{EVENT_START_DATE}" maxlength="255" /></dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt><label for="event_all_day">{L_EVENT_ALL_DAY}:</label></dt>
|
||||
@@ -50,17 +43,10 @@
|
||||
<div id="end"<!-- IF EVENT_ALL_DAY -->style="display: none;"<!-- ENDIF -->>
|
||||
<dl>
|
||||
<dt>
|
||||
<label for="event_end_day">{L_ACP_PORTAL_EVENT_END_DAY}:</label><br />
|
||||
<span>{L_ACP_PORTAL_EVENT_END_DAY_EXP}</span>
|
||||
<label for="event_end_date">{L_ACP_PORTAL_EVENT_END_DATE}:</label><br />
|
||||
<span>{L_ACP_PORTAL_EVENT_END_DATE_EXP}</span>
|
||||
</dt>
|
||||
<dd><input name="event_end_day" type="text" id="event_end_day" value="{EVENT_END_DAY}" maxlength="255" /></dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt>
|
||||
<label for="event_end_time">{L_ACP_PORTAL_EVENT_END_TIME}:</label><br />
|
||||
<span>{L_ACP_PORTAL_EVENT_END_TIME_EXP}</span>
|
||||
</dt>
|
||||
<dd><input name="event_end_time" type="text" id="event_end_time" value="{EVENT_END_TIME}" maxlength="255" /></dd>
|
||||
<dd><input name="event_end_date" type="text" id="event_end_date" value="{EVENT_END_DATE}" maxlength="255" /></dd>
|
||||
</dl>
|
||||
</div>
|
||||
<dl>
|
||||
|
||||
@@ -115,14 +115,10 @@ $lang = array_merge($lang, array(
|
||||
'ACP_PORTAL_CALENDAR_START_INCORRECT' => 'Die eingegebene Start-Zeit ist nicht korrekt. Bitte folge genau den Anweisungen.',
|
||||
'ACP_PORTAL_CALENDAR_END_INCORRECT' => 'Die eingegebene End-Zeit ist nicht korrekt. Bitte folge genau den Anweisungen.',
|
||||
'ACP_PORTAL_CALENDAR_EVENT_PAST' => 'Die Start-zeit der Veranstaltung muss in der Zukunft liegen.',
|
||||
'ACP_PORTAL_EVENT_START_DAY' => 'Start-Datum der Veranstaltung',
|
||||
'ACP_PORTAL_EVENT_START_DAY_EXP' => 'Gebe das Datum ein, an dem die Veranstaltung beginnt. Das Datum muss in folgendem Format sein: TT-MM-JJJJ',
|
||||
'ACP_PORTAL_EVENT_START_TIME' => 'Start-Zeit der Veranstaltung',
|
||||
'ACP_PORTAL_EVENT_START_TIME_EXP' => 'Gebe die Zeit ein, zu der die Veranstaltung beginnt. Die Zeit muss im 24 Stunden Format sein, z.B. 23:12',
|
||||
'ACP_PORTAL_EVENT_END_DAY' => 'End-Datum der Veranstaltung',
|
||||
'ACP_PORTAL_EVENT_END_DAY_EXP' => 'Gebe das Datum ein, an dem die Veranstaltung endet. Das Datum muss in folgendem Format sein: TT-MM-JJJJ',
|
||||
'ACP_PORTAL_EVENT_END_TIME' => 'End-Zeit der Veranstaltung',
|
||||
'ACP_PORTAL_EVENT_END_TIME_EXP' => 'Gebe die Zeit ein, zu der die Veranstaltung endet. Die Zeit muss im 24 Stunden Forrmat sein, z.B. 23:12',
|
||||
'ACP_PORTAL_EVENT_START_DATE' => 'Start-Datum der Veranstaltung',
|
||||
'ACP_PORTAL_EVENT_START_DATE_EXP' => 'Gebe das Datum und Uhrzeit ein, zu der die Veranstaltung beginnt. Datum und Uhrzeit sollten in einem ähnlichen Format sein: TT.MM.JJJJ SS:MM',
|
||||
'ACP_PORTAL_EVENT_END_DATE' => 'End-Datum der Veranstaltung',
|
||||
'ACP_PORTAL_EVENT_END_DATE_EXP' => 'Gebe das Datum und Uhrzeit ein, zu der die Veranstaltung endet. Datum und Uhrzeit sollten in einem ähnlichen Format sein: TT.MM.JJJJ',
|
||||
'ACP_PORTAL_CALENDAR_EVENT_START_FIRST' => 'Das Ende der Veranstaltung muss nach dem Beginn der Veranstaltung liegen.',
|
||||
'ACP_PORTAL_CALENDAR_PERMISSION' => 'Berechtigungen für die Veranstaltung',
|
||||
'ACP_PORTAL_CALENDAR_PERMISSION_EXP' => 'Wähle die Gruppen aus, denen es erlaubt sein soll die Veranstaltung zu sehen. Falls alle Benutzer die Veranstaltung sehen sollen, dann wähle nichts aus.<br />Wähle mehrere Gruppen aus/ab, indem du beim Klicken die <samp>Strg</samp>-Taste drückst.',
|
||||
|
||||
@@ -115,14 +115,10 @@ $lang = array_merge($lang, array(
|
||||
'ACP_PORTAL_CALENDAR_START_INCORRECT' => 'The start time you entered was incorrect. Please follow the instructions carefully.',
|
||||
'ACP_PORTAL_CALENDAR_END_INCORRECT' => 'The end time you entered was incorrect. Please follow the instructions carefully.',
|
||||
'ACP_PORTAL_CALENDAR_EVENT_PAST' => 'The event start time needs to be in the future.',
|
||||
'ACP_PORTAL_EVENT_START_DAY' => 'Event start date',
|
||||
'ACP_PORTAL_EVENT_START_DAY_EXP' => 'Enter the date when the event starts. The date has to be in this format: DD-MM-YYYY',
|
||||
'ACP_PORTAL_EVENT_START_TIME' => 'Event start time',
|
||||
'ACP_PORTAL_EVENT_START_TIME_EXP' => 'Enter the time when the event starts. The time has to be in a 24 hour format, i.e. 23:12',
|
||||
'ACP_PORTAL_EVENT_END_DAY' => 'Event end date',
|
||||
'ACP_PORTAL_EVENT_END_DAY_EXP' => 'Enter the date when the event ends. The date has to be in this format: DD-MM-YYYY',
|
||||
'ACP_PORTAL_EVENT_END_TIME' => 'Event end time',
|
||||
'ACP_PORTAL_EVENT_END_TIME_EXP' => 'Enter the time when the event ends. The time has to be in a 24 hour format, i.e. 23:12',
|
||||
'ACP_PORTAL_EVENT_START_DATE' => 'Event start date',
|
||||
'ACP_PORTAL_EVENT_START_DATE_EXP' => 'Enter the date and time the event starts. The date has to be in a similar format: MM/DD/YYYY 3:00 PM',
|
||||
'ACP_PORTAL_EVENT_END_DATE' => 'Event end date',
|
||||
'ACP_PORTAL_EVENT_END_DATE_EXP' => 'Enter the date and time the event ends. The date has to be in a similar format: MM/DD/YYYY 3:00 PM',
|
||||
'ACP_PORTAL_CALENDAR_EVENT_START_FIRST' => 'The end of the event has to be after the start of the event.',
|
||||
'ACP_PORTAL_CALENDAR_PERMISSION' => 'Event permissions',
|
||||
'ACP_PORTAL_CALENDAR_PERMISSION_EXP' => 'Select the groups that should be authorized to view the event. If you want all users to be able to view the event, don’t select anything.<br />Select/Deselect multiple groups by holding <samp>CTRL</samp> and clicking.',
|
||||
|
||||
@@ -198,10 +198,10 @@ class calendar extends module_base
|
||||
));
|
||||
|
||||
// output the days for the current month
|
||||
for($i = 0; $i < $mini_cal_month_days;)
|
||||
for ($i = 0; $i < $mini_cal_month_days;)
|
||||
{
|
||||
// is this the first day of the week?
|
||||
if($mini_cal_count == $this->mini_cal_fdow)
|
||||
if ($mini_cal_count == $this->mini_cal_fdow)
|
||||
{
|
||||
$this->template->assign_block_vars('minical.mini_cal_row', array(
|
||||
'MODULE_ID' => $module_id,
|
||||
@@ -209,7 +209,7 @@ class calendar extends module_base
|
||||
}
|
||||
|
||||
// is this a valid weekday?
|
||||
if($mini_cal_count == ($this->day[$i][3]))
|
||||
if ($mini_cal_count == ($this->day[$i][3]))
|
||||
{
|
||||
$mini_cal_this_day = $this->day[$i][0];
|
||||
|
||||
@@ -257,10 +257,10 @@ class calendar extends module_base
|
||||
*/
|
||||
$events = $this->utf_unserialize($portal_config['board3_calendar_events_' . $module_id]);
|
||||
|
||||
if(!empty($events) && $this->config['board3_display_events_' . $module_id])
|
||||
if (!empty($events) && $this->config['board3_display_events_' . $module_id])
|
||||
{
|
||||
// we sort the $events array by the start time
|
||||
foreach($events as $key => $cur_event)
|
||||
foreach ($events as $key => $cur_event)
|
||||
{
|
||||
$time_ary[$key] = $cur_event['start_time'];
|
||||
}
|
||||
@@ -268,16 +268,16 @@ class calendar extends module_base
|
||||
|
||||
$groups_ary = get_user_groups();
|
||||
|
||||
foreach($events as $key => $cur_event)
|
||||
foreach ($events as $key => $cur_event)
|
||||
{
|
||||
if(($cur_event['start_time'] + $this->time->getOffset()) >= $today_timestamp ||
|
||||
if (($cur_event['start_time'] + $this->time->getOffset()) >= $today_timestamp ||
|
||||
($cur_event['end_time'] + $this->time->getOffset()) >= $today_timestamp ||
|
||||
(($cur_event['start_time'] + $this->time->getOffset() + self::TIME_DAY) >= $today_timestamp && $cur_event['all_day']))
|
||||
{
|
||||
$cur_permissions = explode(',', $cur_event['permission']);
|
||||
$permission_check = array_intersect($groups_ary, $cur_permissions);
|
||||
|
||||
if(!empty($permission_check) || $cur_event['permission'] == '')
|
||||
if (!empty($permission_check) || $cur_event['permission'] == '')
|
||||
{
|
||||
// check if this is an external link
|
||||
if (isset($cur_event['url']) && strpos($cur_event['url'], generate_board_url()) === false)
|
||||
@@ -296,7 +296,7 @@ class calendar extends module_base
|
||||
* - We have an all day event and the start of that event is less than 1 day (86400 seconds) away
|
||||
* - We have a normal event with a start that is less then 1 day away and that hasn't ended yet
|
||||
*/
|
||||
if((($cur_event['start_time'] + $this->time->getOffset() - $today_timestamp) <= self::TIME_DAY && $cur_event['all_day']) ||
|
||||
if ((($cur_event['start_time'] + $this->time->getOffset() - $today_timestamp) <= self::TIME_DAY && $cur_event['all_day']) ||
|
||||
(($cur_event['start_time'] + $this->time->getOffset() - $today_timestamp) <= self::TIME_DAY && ($cur_event['end_time'] + $this->time->getOffset()) >= $today_timestamp))
|
||||
{
|
||||
$this->template->assign_block_vars('minical.cur_events', array(
|
||||
@@ -417,7 +417,7 @@ class calendar extends module_base
|
||||
// append_sid() adds adm/ already, no need to add it here
|
||||
$u_action = append_sid('index.' . $this->php_ext, 'i=\board3\portal\acp\portal_module&mode=config&module_id=' . $module_id);
|
||||
|
||||
switch($action)
|
||||
switch ($action)
|
||||
{
|
||||
// Save changes
|
||||
case 'save':
|
||||
@@ -428,62 +428,31 @@ class calendar extends module_base
|
||||
|
||||
$event_title = $this->request->variable('event_title', ' ', true);
|
||||
$event_desc = $this->request->variable('event_desc', ' ', true);
|
||||
$event_start_day = trim($this->request->variable('event_start_day', ''));
|
||||
$event_start_time = trim($this->request->variable('event_start_time', ''));
|
||||
$event_end_day = trim($this->request->variable('event_end_day', ''));
|
||||
$event_end_time = trim($this->request->variable('event_end_time', ''));
|
||||
$event_start_date = trim($this->request->variable('event_start_date', ''));
|
||||
$event_end_date = trim($this->request->variable('event_end_date', ''));
|
||||
$event_all_day = $this->request->variable('event_all_day', false); // default to false
|
||||
$event_url = $this->request->variable('event_url', ' ');
|
||||
$event_permission = $this->request->variable('permission-setting-calendar', array(0 => ''));
|
||||
$groups_ary = array();
|
||||
|
||||
/*
|
||||
* parse the event time
|
||||
* first check for obvious errors, we don't want to waste server resources
|
||||
*/
|
||||
if(strlen($event_start_day) < 9 || strlen($event_start_day) > 10 || (strlen($event_start_time) < 4 && !$event_all_day) || strlen($event_start_time) > 5)
|
||||
// Now get the unix timestamps out of the entered information
|
||||
$start_time = $this->date_to_time($event_start_date);
|
||||
$end_time = (!$event_all_day) ? $this->date_to_time($event_end_date) : '';
|
||||
|
||||
if (!$start_time)
|
||||
{
|
||||
trigger_error($this->user->lang['ACP_PORTAL_CALENDAR_START_INCORRECT']. adm_back_link($u_action), E_USER_WARNING);
|
||||
}
|
||||
elseif((strlen($event_end_day) < 9 || strlen($event_end_day) > 10 || strlen($event_end_time) < 4 || strlen($event_end_time) > 5) && !$event_all_day)
|
||||
else if (!$event_all_day && !$end_time)
|
||||
{
|
||||
trigger_error($this->user->lang['ACP_PORTAL_CALENDAR_END_INCORRECT']. adm_back_link($u_action), E_USER_WARNING);
|
||||
}
|
||||
// Now get the needed numbers out of the entered information
|
||||
$first_start_hyphen = strpos($event_start_day, '-', 0);
|
||||
$second_start_hyphen = strpos($event_start_day, '-', $first_start_hyphen + 1);
|
||||
$start_colon_pos = strpos($event_start_time, ':', 0);
|
||||
$start_day_length = strlen($event_start_day);
|
||||
$start_time_length = strlen($event_start_time);
|
||||
$start_day = (int) substr($event_start_day, 0, $first_start_hyphen);
|
||||
$start_month = (int) substr($event_start_day, $first_start_hyphen + 1, ($second_start_hyphen - $first_start_hyphen - 1));
|
||||
$start_year = (int) substr($event_start_day, $second_start_hyphen + 1, $start_day_length - $second_start_hyphen);
|
||||
$start_hour = (int) substr($event_start_time, 0, $start_colon_pos);
|
||||
$start_minute = (int) substr($event_start_time, $start_colon_pos + 1, ($start_time_length - $start_colon_pos) - 1);
|
||||
|
||||
if(!$event_all_day)
|
||||
{
|
||||
$first_end_hyphen = strpos($event_end_day, '-', 0);
|
||||
$second_end_hyphen = strpos($event_end_day, '-', $first_end_hyphen + 1);
|
||||
$end_colon_pos = strpos($event_end_time, ':', 0);
|
||||
$end_day_length = strlen($event_end_day);
|
||||
$end_time_length = strlen($event_end_time);
|
||||
$end_day = (int) substr($event_end_day, 0, $first_end_hyphen);
|
||||
$end_month = (int) substr($event_end_day, $first_end_hyphen + 1, ($second_end_hyphen - $first_end_hyphen - 1));
|
||||
$end_year = (int) substr($event_end_day, $second_end_hyphen + 1, $end_day_length - $second_end_hyphen);
|
||||
$end_hour = (int) substr($event_end_time, 0, $end_colon_pos);
|
||||
$end_minute = (int) substr($event_end_time, $end_colon_pos + 1, ($end_time_length - $end_colon_pos) - 1);
|
||||
}
|
||||
|
||||
// UNIX timestamps
|
||||
$start_time = gmmktime($start_hour, $start_minute, 0, $start_month, $start_day, $start_year);
|
||||
$end_time = (!$event_all_day) ? gmmktime($end_hour, $end_minute, 0, $end_month, $end_day, $end_year) : '';
|
||||
|
||||
if(($end_time) <= time() && !(($start_time + self::TIME_DAY) >= time() && $event_all_day))
|
||||
if (($end_time) <= time() && !(($start_time + self::TIME_DAY) >= time() && $event_all_day))
|
||||
{
|
||||
trigger_error($this->user->lang['ACP_PORTAL_CALENDAR_EVENT_PAST']. adm_back_link($u_action), E_USER_WARNING);
|
||||
}
|
||||
elseif($end_time < $start_time && !$event_all_day)
|
||||
elseif ($end_time < $start_time && !$event_all_day)
|
||||
{
|
||||
trigger_error($this->user->lang['ACP_PORTAL_CALENDAR_EVENT_START_FIRST']. adm_back_link($u_action), E_USER_WARNING);
|
||||
}
|
||||
@@ -493,7 +462,7 @@ class calendar extends module_base
|
||||
FROM ' . GROUPS_TABLE . '
|
||||
ORDER BY group_id ASC';
|
||||
$result = $this->db->sql_query($sql);
|
||||
while($row = $this->db->sql_fetchrow($result))
|
||||
while ($row = $this->db->sql_fetchrow($result))
|
||||
{
|
||||
$groups_ary[] = $row['group_id'];
|
||||
}
|
||||
@@ -547,7 +516,7 @@ class calendar extends module_base
|
||||
}
|
||||
|
||||
// we sort the $events array by the start time
|
||||
foreach($events as $key => $cur_event)
|
||||
foreach ($events as $key => $cur_event)
|
||||
{
|
||||
$time_ary[$key] = $cur_event['start_time'];
|
||||
}
|
||||
@@ -593,14 +562,13 @@ class calendar extends module_base
|
||||
case 'edit':
|
||||
case 'add':
|
||||
$event_all_day = (isset($events[$link_id]['all_day']) && $events[$link_id]['all_day'] == true) ? true : false;
|
||||
$date_format = str_replace(array('D '), '', $this->user->data['user_dateformat']);
|
||||
|
||||
$this->template->assign_vars(array(
|
||||
'EVENT_TITLE' => (isset($events[$link_id]['title']) && $action != 'add') ? $events[$link_id]['title'] : '',
|
||||
'EVENT_DESC' => (isset($events[$link_id]['desc']) && $action != 'add') ? $events[$link_id]['desc'] : '',
|
||||
'EVENT_START_DAY' => ($action != 'add') ? $this->user->format_date($events[$link_id]['start_time'], 'd-m-Y') : '',
|
||||
'EVENT_START_TIME' => ($action != 'add') ? $this->user->format_date($events[$link_id]['start_time'], 'G:i') : '',
|
||||
'EVENT_END_DAY' => ($action != 'add' && !$event_all_day) ? $this->user->format_date($events[$link_id]['end_time'], 'd-m-Y') : '',
|
||||
'EVENT_END_TIME' => ($action != 'add' && !$event_all_day) ? $this->user->format_date($events[$link_id]['end_time'], 'G:i') : '',
|
||||
'EVENT_START_DATE' => ($action != 'add') ? $this->user->format_date($events[$link_id]['start_time'], $date_format) : '',
|
||||
'EVENT_END_DATE' => ($action != 'add' && !$event_all_day) ? $this->user->format_date($events[$link_id]['end_time'], $date_format) : '',
|
||||
'EVENT_ALL_DAY' => (isset($events[$link_id]['all_day']) && $events[$link_id]['all_day'] == true) ? true : false,
|
||||
'EVENT_URL' => (isset($events[$link_id]['url']) && $action != 'add') ? $events[$link_id]['url'] : '',
|
||||
|
||||
@@ -617,7 +585,7 @@ class calendar extends module_base
|
||||
FROM ' . GROUPS_TABLE . '
|
||||
ORDER BY group_id ASC';
|
||||
$result = $this->db->sql_query($sql);
|
||||
while($row = $this->db->sql_fetchrow($result))
|
||||
while ($row = $this->db->sql_fetchrow($result))
|
||||
{
|
||||
$this->template->assign_block_vars('permission_setting_calendar', array(
|
||||
'SELECTED' => (in_array($row['group_id'], $groups_ary)) ? true : false,
|
||||
@@ -785,4 +753,18 @@ class calendar extends module_base
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns timestamp from given date string
|
||||
*
|
||||
* @param string $date Date and time string. It can contain just the
|
||||
* date or date and time info. The string should
|
||||
* be in a similar format: 17.06.1990 18:06
|
||||
* @return int|bool The timestamp of the given date or false if
|
||||
* given daten does not match any known formats.
|
||||
*/
|
||||
public function date_to_time($date)
|
||||
{
|
||||
return strtotime($date);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
|
||||
namespace board3\portal\acp;
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../includes/functions.php');
|
||||
require_once(dirname(__FILE__) . '/../../acp/portal_module.php');
|
||||
require_once(dirname(__FILE__) . '/../../../includes/functions.php');
|
||||
require_once(dirname(__FILE__) . '/../../../acp/portal_module.php');
|
||||
|
||||
class phpbb_acp_move_module_test extends \board3\portal\tests\testframework\database_test_case
|
||||
{
|
||||
@@ -7,8 +7,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../includes/functions.php');
|
||||
require_once(dirname(__FILE__) . '/../../../../../includes/functions_acp.php');
|
||||
require_once(dirname(__FILE__) . '/../../../includes/functions.php');
|
||||
require_once(dirname(__FILE__) . '/../../../../../../includes/functions_acp.php');
|
||||
|
||||
class phpbb_functions_check_file_src_test extends \board3\portal\tests\testframework\database_test_case
|
||||
{
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../includes/functions.php');
|
||||
require_once(dirname(__FILE__) . '/../../../includes/functions.php');
|
||||
|
||||
class phpbb_functions_simple_test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../../../../includes/utf/utf_tools.php');
|
||||
require_once(dirname(__FILE__) . '/../../../../../../includes/utf/utf_tools.php');
|
||||
|
||||
class phpbb_functions_version_check_test extends \board3\portal\tests\testframework\test_case
|
||||
{
|
||||
46
tests/unit/modules/calendar.php
Normal file
46
tests/unit/modules/calendar.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) Board3 Group ( www.board3.de )
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/../../../includes/functions.php');
|
||||
|
||||
class phpbb_functions_simple_test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
$this->path_helper = new \phpbb\path_helper(
|
||||
new \phpbb\symfony_request(
|
||||
new phpbb_mock_request()
|
||||
),
|
||||
new \phpbb\filesystem(),
|
||||
$this->phpbb_root_path,
|
||||
'php'
|
||||
);
|
||||
$this->calendar = new \board3\portal\modules\calendar(array(), null, null, null, dirname(__FILE__) . '/../../../', 'php', null, $this->path_helper);
|
||||
$this->offset = strtotime('17.06.1990') - 645580800;
|
||||
}
|
||||
|
||||
public function data_date_to_time()
|
||||
{
|
||||
return array(
|
||||
array(1402855200, '2014-06-15 18:00'),
|
||||
array(1402855200, '15.06.2014 18:00'),
|
||||
array(1402855200, '06/15/2014 6:00 PM'),
|
||||
array(false, '15/06'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider data_date_to_time
|
||||
*/
|
||||
public function test_date_to_time($expected, $date)
|
||||
{
|
||||
$this->assertEquals($expected, $this->calendar->date_to_time($date) + $this->offset);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user