Index: trunk/phase3/tests/phpunit/includes/XmlTest.php |
— | — | @@ -74,6 +74,16 @@ |
75 | 75 | } |
76 | 76 | |
77 | 77 | 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 | + |
78 | 88 | $this->assertEquals( |
79 | 89 | '<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> |
80 | 90 | <option value="1">January</option> |
— | — | @@ -108,6 +118,35 @@ |
109 | 119 | Xml::dateMenu( 2011, -1), |
110 | 120 | "Date menu with negative month for 'All'" |
111 | 121 | ); |
| 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 | + ); |
112 | 151 | } |
113 | 152 | |
114 | 153 | # |