Index: trunk/extensions/Contest/test/ContestValidationTests.php |
— | — | @@ -0,0 +1,38 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Contest form field validation tests cases. |
| 6 | + * |
| 7 | + * @ingroup Contest |
| 8 | + * @since 0.1 |
| 9 | + * |
| 10 | + * @licence GNU GPL v3 |
| 11 | + * @author Jeroen De Dauw < jeroendedauw@gmail.com > |
| 12 | + */ |
| 13 | +class ContestValidationTests extends MediaWikiTestCase { |
| 14 | + |
| 15 | + /** |
| 16 | + * Tests |
| 17 | + */ |
| 18 | + public function testURLValidation() { |
| 19 | + $tests = array( |
| 20 | + 'https://github.com/JeroenDeDauw/smwcon/tree/f9b26ec4ba1101b1f5d4ef76b7ae6ad3dabfb53b' => true, |
| 21 | + 'https://github.com/Jeroen-De-Dauw42/smwcon_-42/tree/f9b26ec4ba1101b1f5d4ef76b7ae6ad3dabfb53b' => true, |
| 22 | + 'https://github.com/JeroenDeDauw$/smwcon/tree/f9b26ec4ba1101b1f5d4ef76b7ae6ad3dabfb53b' => false, |
| 23 | + 'https://github.com/JeroenDeDauw/smwcon/tree3/f9b26ec4ba1101b1f5d4ef76b7ae6ad3dabfb53b' => false, |
| 24 | + 'https://github.com/JeroenDeDauw/smwcon/tree/f9b26ec4ba1101b1f5d4ef76b7ae6ad3dabfb53' => false, |
| 25 | + 'https://github.com/JeroenDeDauw/smwcon/tree/f9b26ec4ba1101b1f5d4ef76b7ae6ad3dabfb53ba' => false, |
| 26 | + 'https://github.com/JeroenDeDauw/smwc*/tree/f9b26ec4ba1101b1f5d4ef76b7ae6ad3dabfb53b' => false, |
| 27 | + ); |
| 28 | + |
| 29 | + foreach ( $tests as $test => $isValdid ) { |
| 30 | + if ( $isValdid ) { |
| 31 | + $this->assertEquals( true, SpecialContestSubmission::validateSubmissionField( $test ) ); |
| 32 | + } |
| 33 | + else { |
| 34 | + $this->assertFalse( SpecialContestSubmission::validateSubmissionField( $test ) === true ); |
| 35 | + } |
| 36 | + } |
| 37 | + } |
| 38 | + |
| 39 | +} |
Index: trunk/extensions/Contest/Contest.hooks.php |
— | — | @@ -163,7 +163,7 @@ |
164 | 164 | public static function registerUnitTests( array &$files ) { |
165 | 165 | $testDir = dirname( __FILE__ ) . '/test/'; |
166 | 166 | |
167 | | - //$files[] = $testDir . 'SurveyQuestionTest.php'; |
| 167 | + $files[] = $testDir . 'ContestValidationTests.php'; |
168 | 168 | |
169 | 169 | return true; |
170 | 170 | } |
Index: trunk/extensions/Contest/specials/SpecialContestSubmission.php |
— | — | @@ -285,7 +285,7 @@ |
286 | 286 | * |
287 | 287 | * @return true|string |
288 | 288 | */ |
289 | | - public function validateSubmissionField( $value, $alldata = null ) { |
| 289 | + public static function validateSubmissionField( $value, $alldata = null ) { |
290 | 290 | $allowedPatterns = array( |
291 | 291 | // GitHub URLs such as https://github.com/JeroenDeDauw/smwcon/tree/f9b26ec4ba1101b1f5d4ef76b7ae6ad3dabfb53b |
292 | 292 | '@^https://github\.com/[a-zA-Z0-9-]+/[a-zA-Z0-9_-]+/tree/[a-zA-Z0-9]{40}$@i' |
Index: trunk/extensions/Contest/specials/SpecialContestant.php |
— | — | @@ -53,6 +53,8 @@ |
54 | 54 | $this->displayNavigation(); |
55 | 55 | |
56 | 56 | $this->showGeneralInfo( $contestant ); |
| 57 | + $this->showRating(); |
| 58 | + $this->showComments(); |
57 | 59 | } |
58 | 60 | } |
59 | 61 | |
— | — | @@ -139,4 +141,27 @@ |
140 | 142 | |
141 | 143 | // TODO: show rating and commenting controls |
142 | 144 | |
| 145 | + /** |
| 146 | + * Display the current rating the judge gave if any and a control to |
| 147 | + * (re)-rate. |
| 148 | + * |
| 149 | + * @since 0.1 |
| 150 | + * |
| 151 | + * @param ContestContestant $contestant |
| 152 | + */ |
| 153 | + protected function showRating( ContestContestant $contestant ) { |
| 154 | + |
| 155 | + } |
| 156 | + |
| 157 | + /** |
| 158 | + * Show the comments and a control to add additional ones. |
| 159 | + * |
| 160 | + * @since 0.1 |
| 161 | + * |
| 162 | + * @param ContestContestant $contestant |
| 163 | + */ |
| 164 | + protected function showComments( ContestContestant $contestant ) { |
| 165 | + |
| 166 | + } |
| 167 | + |
143 | 168 | } |