From 28bab8ff2ec032cd0d1d55c377f3d380c2a5be50 Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Sun, 6 Feb 2011 22:10:48 +0000 Subject: [PATCH] Complete coverage of Xml::DateMenu() r81605 was not hitting all possible conditional tests. Verified with: php phpunit.php --configuration suite.xml \ --coverage-html /tmp/datecover \ --filter DateMenu Tests: PHPUnit 3.5.10 by Sebastian Bergmann. . Time: 3 seconds, Memory: 27.50Mb OK (1 test, 5 assertions) --- tests/phpunit/includes/XmlTest.php | 39 ++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/tests/phpunit/includes/XmlTest.php b/tests/phpunit/includes/XmlTest.php index 080d88731d..4086ce64d0 100644 --- a/tests/phpunit/includes/XmlTest.php +++ b/tests/phpunit/includes/XmlTest.php @@ -74,6 +74,16 @@ class XmlTest extends MediaWikiTestCase { } public function testDateMenu( ) { + $curYear = intval(gmdate('Y')); + $prevYear = $curYear - 1; + + $curMonth = intval(gmdate('n')); + $prevMonth = $curMonth - 1; + if( $prevMonth == 0 ) { $prevMonth = 12; } + $nextMonth = $curMonth + 1; + if( $nextMonth == 13 ) { $nextMonth = 1; } + + $this->assertEquals( ' ', + Xml::dateMenu( '', ''), + "Date menu with neither year or month" + ); } # -- 2.20.1