Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -522,6 +522,8 @@ |
523 | 523 | |
524 | 524 | # Duplicate flagged* tables in parserTests.php |
525 | 525 | $wgHooks['ParserTestTables'][] = 'FlaggedRevsHooks::onParserTestTables'; |
| 526 | +#Unit tests |
| 527 | +$wgHooks['UnitTestsList'][] = 'FlaggedRevsHooks::getUnitTests'; |
526 | 528 | |
527 | 529 | # Database schema changes |
528 | 530 | $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 @@ |
3 | 3 | |
4 | 4 | require_once 'PHPUnit\Framework\TestCase.php'; |
5 | 5 | |
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 | | - |
40 | 6 | class FRInclusionManagerTest extends PHPUnit_Framework_TestCase { |
41 | 7 | /* starting input */ |
42 | 8 | protected static $inputTemplates = array( |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php |
— | — | @@ -1799,8 +1799,11 @@ |
1800 | 1800 | } |
1801 | 1801 | |
1802 | 1802 | 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 | + } |
1805 | 1808 | return true; |
1806 | 1809 | } |
1807 | 1810 | |
— | — | @@ -2060,6 +2063,11 @@ |
2061 | 2064 | return true; |
2062 | 2065 | } |
2063 | 2066 | |
| 2067 | + public static function getUnitTests( &$files ) { |
| 2068 | + $files[] = dirname( __FILE__ ) . '/maintenance/tests/FRInclusionManagerTest.php'; |
| 2069 | + return true; |
| 2070 | + } |
| 2071 | + |
2064 | 2072 | public static function onParserTestTables( array &$tables ) { |
2065 | 2073 | $tables[] = 'flaggedpages'; |
2066 | 2074 | $tables[] = 'flaggedrevs'; |