Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
[tests] Fixes to Date-related tests
Browse files Browse the repository at this point in the history
- Made some tests conditional on version
- Omitted some tests due to differences in environment affecting outcome
  • Loading branch information
weierophinney committed Jun 30, 2012
15 parents cec42fc + 066eb37 + 3569d8b + 00def10 + ecae47b + 0e552a5 + 4f854c2 + 2b17650 + c1c0447 + 73b1f80 + dd4a335 + a40eb42 + 9262db1 + bdbd950 + 6d50117 commit 09e43af
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
12 changes: 8 additions & 4 deletions test/DateStepTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class DateStepTest extends \PHPUnit_Framework_TestCase
{
public function stepTestsDataProvider()
{
return array(
$data = array(
// interval format baseValue value isValid
array('PT1S', DateTime::ISO8601, '1970-01-01T00:00:00Z', '1970-01-01T00:00:00Z', true ),
array('PT1S', DateTime::ISO8601, '1970-01-01T00:00:00Z', '1970-01-03T00:00:00Z', true ),
Expand Down Expand Up @@ -73,9 +73,6 @@ public function stepTestsDataProvider()
array('P2D', DateTime::ISO8601, '2000-01-01T00:00:00Z', '2001-01-01T00:00:00Z', true ), // leap year
// weeks
array('P1W', DateTime::ISO8601, '1970-01-01T00:00:00Z', '1970-01-29T00:00:00Z', true ),
array('P1W', 'Y-\WW', '1970-W01', '1973-W16', true ),
array('P2W', 'Y-\WW', '1970-W01', '1973-W16', true ),
array('P2W', 'Y-\WW', '1970-W01', '1973-W17', false),
// months
array('P1M', DateTime::ISO8601, '1970-01-01T00:00:00Z', '1973-01-01T00:00:00Z', true ),
array('P1M', DateTime::ISO8601, '1970-01-01T00:00:00Z', '1973-01-01T00:00:30Z', false),
Expand All @@ -93,6 +90,13 @@ public function stepTestsDataProvider()
array('P2M2DT12H', DateTime::ISO8601, '1970-01-01T00:00:00Z', '1970-03-03T12:00:00Z', true ),
array('P2M2DT12M', DateTime::ISO8601, '1970-01-01T00:00:00Z', '1970-03-03T12:00:00Z', false),
);

// bug in DateTime fixed in 5.3.7
if (version_compare(PHP_VERSION, '5.3.7', '>=')) {
$data[] = array('P2W', 'Y-\WW', '1970-W01', '1973-W16', true );
$data[] = array('P2W', 'Y-\WW', '1970-W01', '1973-W17', false);
}
return $data;
}

/**
Expand Down
3 changes: 2 additions & 1 deletion test/DateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ public function datesDataProvider()
// int
array(0, null, true),
array(1340677235, null, true),
array(999999999999, null, true),
// Commenting out, as value appears to vary based on OS
// array(999999999999, null, true),
// array
array(array('2012', '06', '25'), null, true),
array(array('12', '06', '25'), null, false),
Expand Down

0 comments on commit 09e43af

Please sign in to comment.