r99285 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99284‎ | r99285 | r99286 >
Date:00:04, 8 October 2011
Author:jeroendedauw
Status:resolved (Comments)
Tags:
Comment:
added test
Modified paths:
  • /trunk/extensions/Contest/Contest.hooks.php (modified) (history)
  • /trunk/extensions/Contest/specials/SpecialContestSubmission.php (modified) (history)
  • /trunk/extensions/Contest/specials/SpecialContestant.php (modified) (history)
  • /trunk/extensions/Contest/test/ContestValidationTests.php (added) (history)

Diff [purge]

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 @@
164164 public static function registerUnitTests( array &$files ) {
165165 $testDir = dirname( __FILE__ ) . '/test/';
166166
167 - //$files[] = $testDir . 'SurveyQuestionTest.php';
 167+ $files[] = $testDir . 'ContestValidationTests.php';
168168
169169 return true;
170170 }
Index: trunk/extensions/Contest/specials/SpecialContestSubmission.php
@@ -285,7 +285,7 @@
286286 *
287287 * @return true|string
288288 */
289 - public function validateSubmissionField( $value, $alldata = null ) {
 289+ public static function validateSubmissionField( $value, $alldata = null ) {
290290 $allowedPatterns = array(
291291 // GitHub URLs such as https://github.com/JeroenDeDauw/smwcon/tree/f9b26ec4ba1101b1f5d4ef76b7ae6ad3dabfb53b
292292 '@^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 @@
5454 $this->displayNavigation();
5555
5656 $this->showGeneralInfo( $contestant );
 57+ $this->showRating();
 58+ $this->showComments();
5759 }
5860 }
5961
@@ -139,4 +141,27 @@
140142
141143 // TODO: show rating and commenting controls
142144
 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+
143168 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r99288follow up to r99285jeroendedauw00:20, 8 October 2011
r100190Fix typo...reedy23:58, 18 October 2011

Comments

#Comment by Hashar (talk | contribs)   13:05, 6 December 2011

r100190 fixes isValdid :-)

Status & tagging log