|
|
@ -405,6 +405,7 @@ class FormatterDateTest extends TestCase |
|
|
|
|
|
|
|
|
|
|
|
public function testAsDuration() |
|
|
|
public function testAsDuration() |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
$interval_0_seconds = new DateInterval("PT0S"); |
|
|
|
$interval_1_second = new DateInterval("PT1S"); |
|
|
|
$interval_1_second = new DateInterval("PT1S"); |
|
|
|
$interval_244_seconds = new DateInterval("PT244S"); |
|
|
|
$interval_244_seconds = new DateInterval("PT244S"); |
|
|
|
$interval_1_minute = new DateInterval("PT1M"); |
|
|
|
$interval_1_minute = new DateInterval("PT1M"); |
|
|
@ -419,6 +420,7 @@ class FormatterDateTest extends TestCase |
|
|
|
$interval_12_years = new DateInterval("P12Y"); |
|
|
|
$interval_12_years = new DateInterval("P12Y"); |
|
|
|
|
|
|
|
|
|
|
|
// Pass a DateInterval |
|
|
|
// Pass a DateInterval |
|
|
|
|
|
|
|
$this->assertSame('0 seconds', $this->formatter->asDuration($interval_0_seconds)); |
|
|
|
$this->assertSame('1 second', $this->formatter->asDuration($interval_1_second)); |
|
|
|
$this->assertSame('1 second', $this->formatter->asDuration($interval_1_second)); |
|
|
|
$this->assertSame('244 seconds', $this->formatter->asDuration($interval_244_seconds)); |
|
|
|
$this->assertSame('244 seconds', $this->formatter->asDuration($interval_244_seconds)); |
|
|
|
$this->assertSame('1 minute', $this->formatter->asDuration($interval_1_minute)); |
|
|
|
$this->assertSame('1 minute', $this->formatter->asDuration($interval_1_minute)); |
|
|
@ -432,6 +434,16 @@ class FormatterDateTest extends TestCase |
|
|
|
$this->assertSame('1 year', $this->formatter->asDuration($interval_1_year)); |
|
|
|
$this->assertSame('1 year', $this->formatter->asDuration($interval_1_year)); |
|
|
|
$this->assertSame('12 years', $this->formatter->asDuration($interval_12_years)); |
|
|
|
$this->assertSame('12 years', $this->formatter->asDuration($interval_12_years)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Pass a numeric value |
|
|
|
|
|
|
|
$this->assertSame('0 seconds', $this->formatter->asDuration(0)); |
|
|
|
|
|
|
|
$this->assertSame('1 second', $this->formatter->asDuration(1)); |
|
|
|
|
|
|
|
$this->assertSame('4 minutes, 4 seconds', $this->formatter->asDuration(244)); |
|
|
|
|
|
|
|
$this->assertSame('1 minute', $this->formatter->asDuration(60)); |
|
|
|
|
|
|
|
$this->assertSame('33 minutes', $this->formatter->asDuration(1980)); |
|
|
|
|
|
|
|
$this->assertSame('1 hour', $this->formatter->asDuration(3600)); |
|
|
|
|
|
|
|
$this->assertSame('6 hours', $this->formatter->asDuration(21600)); |
|
|
|
|
|
|
|
$this->assertSame('1 day', $this->formatter->asDuration(86400)); |
|
|
|
|
|
|
|
|
|
|
|
// Pass a DateInterval string |
|
|
|
// Pass a DateInterval string |
|
|
|
$this->assertSame('1 year, 2 months, 10 days, 2 hours, 30 minutes', $this->formatter->asDuration('2007-03-01T13:00:00Z/2008-05-11T15:30:00Z')); |
|
|
|
$this->assertSame('1 year, 2 months, 10 days, 2 hours, 30 minutes', $this->formatter->asDuration('2007-03-01T13:00:00Z/2008-05-11T15:30:00Z')); |
|
|
|
$this->assertSame('1 year, 2 months, 10 days, 2 hours, 30 minutes', $this->formatter->asDuration('2007-03-01T13:00:00Z/P1Y2M10DT2H30M')); |
|
|
|
$this->assertSame('1 year, 2 months, 10 days, 2 hours, 30 minutes', $this->formatter->asDuration('2007-03-01T13:00:00Z/P1Y2M10DT2H30M')); |
|
|
@ -442,6 +454,7 @@ class FormatterDateTest extends TestCase |
|
|
|
$this->assertSame('-94 months', $this->formatter->asDuration('P-94M')); |
|
|
|
$this->assertSame('-94 months', $this->formatter->asDuration('P-94M')); |
|
|
|
|
|
|
|
|
|
|
|
// Invert all the DateIntervals |
|
|
|
// Invert all the DateIntervals |
|
|
|
|
|
|
|
$interval_0_seconds->invert = true; |
|
|
|
$interval_1_second->invert = true; |
|
|
|
$interval_1_second->invert = true; |
|
|
|
$interval_244_seconds->invert = true; |
|
|
|
$interval_244_seconds->invert = true; |
|
|
|
$interval_1_minute->invert = true; |
|
|
|
$interval_1_minute->invert = true; |
|
|
@ -456,6 +469,7 @@ class FormatterDateTest extends TestCase |
|
|
|
$interval_12_years->invert = true; |
|
|
|
$interval_12_years->invert = true; |
|
|
|
|
|
|
|
|
|
|
|
// Pass a inverted DateInterval |
|
|
|
// Pass a inverted DateInterval |
|
|
|
|
|
|
|
$this->assertSame('0 seconds', $this->formatter->asDuration($interval_0_seconds)); |
|
|
|
$this->assertSame('-1 second', $this->formatter->asDuration($interval_1_second)); |
|
|
|
$this->assertSame('-1 second', $this->formatter->asDuration($interval_1_second)); |
|
|
|
$this->assertSame('-244 seconds', $this->formatter->asDuration($interval_244_seconds)); |
|
|
|
$this->assertSame('-244 seconds', $this->formatter->asDuration($interval_244_seconds)); |
|
|
|
$this->assertSame('-1 minute', $this->formatter->asDuration($interval_1_minute)); |
|
|
|
$this->assertSame('-1 minute', $this->formatter->asDuration($interval_1_minute)); |
|
|
|