mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
[feature/new-tz-handling] Add tests for get_timestamp_from_format()
PHPBB3-9558
This commit is contained in:
parent
3e3489195f
commit
72c3148cfe
1 changed files with 57 additions and 0 deletions
57
tests/datetime/from_format_test.php
Normal file
57
tests/datetime/from_format_test.php
Normal file
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/session.php';
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/user.php';
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/datetime.php';
|
||||
require_once dirname(__FILE__) . '/../mock/lang.php';
|
||||
|
||||
class phpbb_datetime_from_format_test extends phpbb_test_case
|
||||
{
|
||||
public function from_format_data()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
'UTC',
|
||||
'Y-m-d',
|
||||
'2012-06-08',
|
||||
),
|
||||
|
||||
array(
|
||||
'Europe/Berlin',
|
||||
'Y-m-d H:i:s',
|
||||
'2012-06-08 14:01:02',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider from_format_data()
|
||||
*/
|
||||
public function test_from_format($timezone, $format, $expected)
|
||||
{
|
||||
global $user;
|
||||
|
||||
$user = new phpbb_user();
|
||||
$user->tz = new DateTimeZone($timezone);
|
||||
$user->lang['datetime'] = array(
|
||||
'TODAY' => 'Today',
|
||||
'TOMORROW' => 'Tomorrow',
|
||||
'YESTERDAY' => 'Yesterday',
|
||||
'AGO' => array(
|
||||
0 => 'less than a minute ago',
|
||||
1 => '%d minute ago',
|
||||
2 => '%d minutes ago',
|
||||
),
|
||||
);
|
||||
|
||||
$timestamp = $user->get_timestamp_from_format($format, $expected, new DateTimeZone($timezone));
|
||||
$this->assertEquals($expected, $user->format_date($timestamp, $format, true));
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue