Skip to content

Commit

Permalink
Make expected result a callable in Timezone dataprovider
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halsall committed Jun 28, 2017
1 parent 48d5b12 commit cb12ace
Showing 1 changed file with 40 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function getConvertConfigTimeToUtcFixtures()
/**
* @dataProvider getDateFixtures
*/
public function testDate($expectedResult, $timezone = 'UTC', $date = null)
public function testDate(callable $expectedResult, $timezone = 'UTC', $date = null)
{
$this->localeResolver
->method('getLocale')
Expand All @@ -130,7 +130,7 @@ public function testDate($expectedResult, $timezone = 'UTC', $date = null)
$this->scopeConfigWillReturnConfiguredTimezone($timezone);

$this->assertEquals(
$expectedResult,
$expectedResult(),
$this->getTimezone()->date($date, null, true),
'',
1
Expand All @@ -144,12 +144,44 @@ public function getDateFixtures()
date_default_timezone_set('UTC');

return [
'now_datetime_utc' => [new \DateTime('now', new \DateTimeZone('UTC')), 'UTC'],
'fixed_datetime_utc' => [new \DateTime('2017-01-01 10:00:00', new \DateTimeZone('UTC')), 'UTC', new \DateTime('2017-01-01 10:00:00')],
'now_datetime_vancouver' => [new \DateTime('now', new \DateTimeZone('America/Vancouver')), 'America/Vancouver'],
'now_datetimeimmutable_utc' => [new \DateTimeImmutable('now', new \DateTimeZone('UTC')), 'UTC'],
'fixed_datetimeimmutable_utc' => [new \DateTime('2017-01-01 10:00:00', new \DateTimeZone('UTC')), 'UTC', new \DateTimeImmutable('2017-01-01 10:00:00')],
'now_datetimeimmutable_vancouver' => [new \DateTimeImmutable('now', new \DateTimeZone('America/Vancouver')), 'America/Vancouver'],
'now_datetime_utc' => [
function () {
return new \DateTime('now', new \DateTimeZone('UTC'));
},
'UTC'
],
'fixed_datetime_utc' => [
function () {
return new \DateTime('2017-01-01 10:00:00', new \DateTimeZone('UTC'));
},
'UTC',
new \DateTime('2017-01-01 10:00:00')
],
'now_datetime_vancouver' => [
function () {
return new \DateTime('now', new \DateTimeZone('America/Vancouver'));
},
'America/Vancouver'
],
'now_datetimeimmutable_utc' => [
function () {
return new \DateTimeImmutable('now', new \DateTimeZone('UTC'));
},
'UTC'
],
'fixed_datetimeimmutable_utc' => [
function () {
return new \DateTime('2017-01-01 10:00:00', new \DateTimeZone('UTC'));
},
'UTC',
new \DateTimeImmutable('2017-01-01 10:00:00')
],
'now_datetimeimmutable_vancouver' => [
function () {
return new \DateTimeImmutable('now', new \DateTimeZone('America/Vancouver'));
},
'America/Vancouver'
],
];
}

Expand Down

0 comments on commit cb12ace

Please sign in to comment.