diff options
-rw-r--r-- | core/Period.php | 3 | ||||
m--------- | tests/PHPUnit/UI | 0 | ||||
-rw-r--r-- | tests/PHPUnit/Unit/Period/RangeTest.php | 15 |
3 files changed, 14 insertions, 4 deletions
diff --git a/core/Period.php b/core/Period.php index 1e3f188b5e..6de6fb485a 100644 --- a/core/Period.php +++ b/core/Period.php @@ -263,8 +263,9 @@ abstract class Period abstract public function getLocalizedLongString(); /** - * Returns a succinct string describing this period. + * Returns the date range string comprising two dates * + * @api * @return string eg, `'2012-01-01,2012-01-31'`. */ public function getRangeString() diff --git a/tests/PHPUnit/UI b/tests/PHPUnit/UI -Subproject b9a5d064d033a645f169c6da8a2279c2f065e1e +Subproject 92262f979840f6ac0935b769bf73bda47bf8af0 diff --git a/tests/PHPUnit/Unit/Period/RangeTest.php b/tests/PHPUnit/Unit/Period/RangeTest.php index 7c92d2119f..29c716d68b 100644 --- a/tests/PHPUnit/Unit/Period/RangeTest.php +++ b/tests/PHPUnit/Unit/Period/RangeTest.php @@ -137,7 +137,8 @@ class Period_RangeTest extends \PHPUnit_Framework_TestCase public function testRangeComma2() { - $range = new Range('day', '2007-12-22,2008-01-03'); + $rangeString = '2007-12-22,2008-01-03'; + $range = new Range('day', $rangeString); $correct = array( '2007-12-22', @@ -157,6 +158,7 @@ class Period_RangeTest extends \PHPUnit_Framework_TestCase $this->assertEquals(13, $range->getNumberOfSubperiods()); $this->assertEquals($correct, $range->toString()); + $this->assertEquals($rangeString, $range->getRangeString()); } // test range date1,date2 @@ -166,7 +168,8 @@ class Period_RangeTest extends \PHPUnit_Framework_TestCase public function testRangeWeekcomma1() { $range = new Range('week', '2007-12-22,2008-01-03'); - $range2 = new Range('week', '2007-12-19,2008-01-03'); + $range2String = '2007-12-19,2008-01-03'; + $range2 = new Range('week', $range2String); $correct = array( array( @@ -202,6 +205,7 @@ class Period_RangeTest extends \PHPUnit_Framework_TestCase $this->assertEquals(count($correct), $range2->getNumberOfSubperiods()); $this->assertEquals($correct, $range->toString()); $this->assertEquals($correct, $range2->toString()); + $this->assertEquals('2007-12-17,2008-01-06' , $range2->getRangeString()); } // test range date1,date2 @@ -245,6 +249,7 @@ class Period_RangeTest extends \PHPUnit_Framework_TestCase ); $this->assertEquals(count($correct), $range->getNumberOfSubperiods()); $this->assertEquals($correct, $range->toString()); + $this->assertEquals('2006-01-01,2007-12-31', $range->getRangeString()); } // test range date1,date2 @@ -326,6 +331,7 @@ class Period_RangeTest extends \PHPUnit_Framework_TestCase $this->assertEquals(count($correct), $range->getNumberOfSubperiods()); $this->assertEquals($correct, $range->toString()); + $this->assertEquals('2006-12-01,2007-01-31', $range->getRangeString()); } // test range WEEK @@ -654,7 +660,8 @@ class Period_RangeTest extends \PHPUnit_Framework_TestCase */ public function testCustomRangeYear_UsesCurrentYear() { - $range = new Range('range', '2013-01-01,2013-11-01', 'UTC', Date::factory('2013-11-01')); + $rangeString = '2013-01-01,2013-11-01'; + $range = new Range('range', $rangeString, 'UTC', Date::factory('2013-11-01')); $year2013 = new Year(Date::factory('2013-02-02')); $correct = array( @@ -663,6 +670,8 @@ class Period_RangeTest extends \PHPUnit_Framework_TestCase $this->assertEquals(1, $range->getNumberOfSubperiods()); $this->assertEquals($correct, $range->toString()); + $this->assertEquals($correct, $range->toString()); + $this->assertEquals($rangeString, $range->getRangeString()); } /** |