r81609 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81608‎ | r81609 | r81610 >
Date:22:10, 6 February 2011
Author:hashar
Status:ok
Tags:
Comment:
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)
Modified paths:
  • /trunk/phase3/tests/phpunit/includes/XmlTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/XmlTest.php
@@ -74,6 +74,16 @@
7575 }
7676
7777 public function testDateMenu( ) {
 78+ $curYear = intval(gmdate('Y'));
 79+ $prevYear = $curYear - 1;
 80+
 81+ $curMonth = intval(gmdate('n'));
 82+ $prevMonth = $curMonth - 1;
 83+ if( $prevMonth == 0 ) { $prevMonth = 12; }
 84+ $nextMonth = $curMonth + 1;
 85+ if( $nextMonth == 13 ) { $nextMonth = 1; }
 86+
 87+
7888 $this->assertEquals(
7989 '<label for="year">From year (and earlier):</label> <input name="year" size="4" value="2011" id="year" maxlength="4" /> <label for="month">From month (and earlier):</label> <select id="month" name="month" class="mw-month-selector"><option value="-1">all</option>
8090 <option value="1">January</option>
@@ -108,6 +118,35 @@
109119 Xml::dateMenu( 2011, -1),
110120 "Date menu with negative month for 'All'"
111121 );
 122+ $this->assertEquals(
 123+ Xml::dateMenu( $curYear, $curMonth ),
 124+ Xml::dateMenu( '' , $curMonth ),
 125+ "Date menu year is the current one when not specified"
 126+ );
 127+ $this->assertEquals(
 128+ Xml::dateMenu( $prevYear, $nextMonth ),
 129+ Xml::dateMenu( '', $nextMonth ),
 130+ "Date menu next month is 11 months ago"
 131+ );
 132+
 133+ # FIXME: please note there is no year there!
 134+ $this->assertEquals(
 135+ '<label for="year">From year (and earlier):</label> <input name="year" size="4" value="" id="year" maxlength="4" /> <label for="month">From month (and earlier):</label> <select id="month" name="month" class="mw-month-selector"><option value="-1">all</option>
 136+<option value="1">January</option>
 137+<option value="2">February</option>
 138+<option value="3">March</option>
 139+<option value="4">April</option>
 140+<option value="5">May</option>
 141+<option value="6">June</option>
 142+<option value="7">July</option>
 143+<option value="8">August</option>
 144+<option value="9">September</option>
 145+<option value="10">October</option>
 146+<option value="11">November</option>
 147+<option value="12">December</option></select>',
 148+ Xml::dateMenu( '', ''),
 149+ "Date menu with neither year or month"
 150+ );
112151 }
113152
114153 #

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r81605Tests for Xml::DateMenu()hashar21:23, 6 February 2011

Status & tagging log