r69863 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69862‎ | r69863 | r69864 >
Date:08:13, 25 July 2010
Author:aaron
Status:ok (Comments)
Tags:
Comment:
* Test cleanups
* Fixed injectPostEditURLParams to not fail on tests
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/maintenance/tests/FRInclusionManagerTest.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/maintenance/tests/FlaggedRevsTestSuite.php (deleted) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -522,6 +522,8 @@
523523
524524 # Duplicate flagged* tables in parserTests.php
525525 $wgHooks['ParserTestTables'][] = 'FlaggedRevsHooks::onParserTestTables';
 526+#Unit tests
 527+$wgHooks['UnitTestsList'][] = 'FlaggedRevsHooks::getUnitTests';
526528
527529 # Database schema changes
528530 $wgHooks['LoadExtensionSchemaUpdates'][] = 'FlaggedRevsHooks::addSchemaUpdates';
Index: trunk/extensions/FlaggedRevs/maintenance/tests/FlaggedRevsTestSuite.php
@@ -1,20 +0,0 @@
2 -<?php
3 -
4 -require_once 'PHPUnit\Framework\TestSuite.php';
5 -
6 -class FlaggedRevsTestSuite extends PHPUnit_Framework_TestSuite {
7 - /**
8 - * Constructs the test suite handler.
9 - */
10 - public function __construct() {
11 - $this->setName( 'FlaggedRevs' );
12 - $this->addTestSuite( 'FRInclusionManagerTest' );
13 - }
14 -
15 - /**
16 - * Creates the suite.
17 - */
18 - public static function suite() {
19 - return new self();
20 - }
21 -}
Index: trunk/extensions/FlaggedRevs/maintenance/tests/FRInclusionManagerTest.php
@@ -2,40 +2,6 @@
33
44 require_once 'PHPUnit\Framework\TestCase.php';
55
6 -define( 'MEDIAWIKI', 1 ); // hack
7 -if ( getenv( 'MW_INSTALL_PATH' ) ) {
8 - $IP = getenv( 'MW_INSTALL_PATH' );
9 -} else {
10 - $IP = dirname(__FILE__).'/../../../..';
11 -}
12 -require_once "$IP/includes/defines.php"; // constants (NS_FILE ect...)
13 -require_once dirname(__FILE__).'/../../FRInclusionManager.php';
14 -
15 -##### Fake classes for dependencies ####
16 -class Title {
17 - protected $ns;
18 - protected $dbKey;
19 - public static function makeTitleSafe( $ns, $dbKey ) {
20 - $t = new self();
21 - $t->ns = (int)$ns;
22 - $t->dbKey = (string)$dbKey;
23 - return $t;
24 - }
25 - public function getNamespace() {
26 - return $this->ns;
27 - }
28 - public function getDBKey() {
29 - return $this->dbKey;
30 - }
31 -}
32 -class FlaggedRevision {
33 - public static function newFromStable() {
34 - return null; // not in DB
35 - }
36 -}
37 -class MWException extends Exception { } // just in case
38 -##### End fake classes #####
39 -
406 class FRInclusionManagerTest extends PHPUnit_Framework_TestCase {
417 /* starting input */
428 protected static $inputTemplates = array(
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php
@@ -1799,8 +1799,11 @@
18001800 }
18011801
18021802 public static function injectPostEditURLParams( $article, &$sectionAnchor, &$extraQuery ) {
1803 - $view = FlaggedArticleView::singleton();
1804 - $view->injectPostEditURLParams( $sectionAnchor, $extraQuery );
 1803+ // Note: $wgArticle sometimes not set here
 1804+ if ( FlaggedArticleView::globalArticleInstance() != null ) {
 1805+ $view = FlaggedArticleView::singleton();
 1806+ $view->injectPostEditURLParams( $sectionAnchor, $extraQuery );
 1807+ }
18051808 return true;
18061809 }
18071810
@@ -2060,6 +2063,11 @@
20612064 return true;
20622065 }
20632066
 2067+ public static function getUnitTests( &$files ) {
 2068+ $files[] = dirname( __FILE__ ) . '/maintenance/tests/FRInclusionManagerTest.php';
 2069+ return true;
 2070+ }
 2071+
20642072 public static function onParserTestTables( array &$tables ) {
20652073 $tables[] = 'flaggedpages';
20662074 $tables[] = 'flaggedrevs';

Comments

#Comment by Aaron Schulz (talk | contribs)   08:13, 25 July 2010

Follows-up r69824

Status & tagging log