Index: trunk/phase3/tests/phpunit/includes/parser/NewParserTest.php |
— | — | @@ -1,7 +1,5 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | | -require_once( dirname( __FILE__ ) . '/NewParserHelpers.php' ); |
5 | | - |
6 | 4 | /** |
7 | 5 | * @group Database |
8 | 6 | */ |
— | — | @@ -12,6 +10,8 @@ |
13 | 11 | public $runDisabled = false; |
14 | 12 | public $regex = ''; |
15 | 13 | public $showProgress = true; |
| 14 | + public $savedInitialGlobals = array(); |
| 15 | + public $savedWeirdGlobals = array(); |
16 | 16 | public $savedGlobals = array(); |
17 | 17 | public $hooks = array(); |
18 | 18 | public $functionHooks = array(); |
— | — | @@ -26,7 +26,7 @@ |
27 | 27 | //PHPUnit + MediaWikiTestCase functions |
28 | 28 | |
29 | 29 | function setUp() { |
30 | | - global $wgContLang; |
| 30 | + global $wgContLang, $wgUseDatabaseMessages, $wgMsgCacheExpiry, $wgNamespaceProtection, $wgNamespaceAliases; |
31 | 31 | $wgContLang = Language::factory( 'en' ); |
32 | 32 | |
33 | 33 | |
— | — | @@ -41,22 +41,15 @@ |
42 | 42 | |
43 | 43 | $this->keepUploads = $this->getCliArg( 'keep-uploads' ); |
44 | 44 | |
45 | | - |
46 | | - |
47 | | - global $wgParser, $wgParserConf, $IP, $messageMemc, $wgMemc, $wgDeferredUpdateList, |
48 | | - $wgUser, $wgLang, $wgOut, $wgRequest, $wgStyleDirectory, $wgEnableParserCache, |
49 | | - $wgMessageCache, $wgUseDatabaseMessages, $wgMsgCacheExpiry, $parserMemc, |
50 | | - $wgNamespaceAliases, $wgNamespaceProtection, $wgLocalFileRepo, |
51 | | - $wgThumbnailScriptPath, $wgScriptPath, |
52 | | - $wgArticlePath, $wgStyleSheetPath, $wgScript, $wgStylePath; |
53 | | - |
54 | | - $wgScript = '/index.php'; |
55 | | - $wgScriptPath = '/'; |
56 | | - $wgArticlePath = '/wiki/$1'; |
57 | | - $wgStyleSheetPath = '/skins'; |
58 | | - $wgStylePath = '/skins'; |
59 | | - $wgThumbnailScriptPath = false; |
60 | | - $wgLocalFileRepo = array( |
| 45 | + $tmpGlobals = array(); |
| 46 | + |
| 47 | + $tmpGlobals['wgScript'] = '/index.php'; |
| 48 | + $tmpGlobals['wgScriptPath'] = '/'; |
| 49 | + $tmpGlobals['wgArticlePath'] = '/wiki/$1'; |
| 50 | + $tmpGlobals['wgStyleSheetPath'] = '/skins'; |
| 51 | + $tmpGlobals['wgStylePath'] = '/skins'; |
| 52 | + $tmpGlobals['wgThumbnailScriptPath'] = false; |
| 53 | + $tmpGlobals['wgLocalFileRepo'] = array( |
61 | 54 | 'class' => 'LocalRepo', |
62 | 55 | 'name' => 'local', |
63 | 56 | 'directory' => wfTempDir() . '/test-repo', |
— | — | @@ -65,34 +58,59 @@ |
66 | 59 | 'hashLevels' => 2, |
67 | 60 | 'transformVia404' => false, |
68 | 61 | ); |
69 | | - $wgNamespaceProtection[NS_MEDIAWIKI] = 'editinterface'; |
70 | | - $wgNamespaceAliases['Image'] = NS_FILE; |
71 | | - $wgNamespaceAliases['Image_talk'] = NS_FILE_TALK; |
| 62 | + |
| 63 | + var_dump(2); |
72 | 64 | |
73 | | - |
74 | | - $wgEnableParserCache = false; |
75 | | - $wgDeferredUpdateList = array(); |
76 | | - $wgMemc = &wfGetMainCache(); |
| 65 | + $tmpGlobals['wgEnableParserCache'] = false; |
| 66 | + $tmpGlobals['wgDeferredUpdateList'] = array(); |
| 67 | + $tmpGlobals['wgMemc'] = &wfGetMainCache(); |
77 | 68 | $messageMemc = &wfGetMessageCacheStorage(); |
78 | | - $parserMemc = &wfGetParserCacheStorage(); |
| 69 | + $tmpGlobals['parserMemc'] = &wfGetParserCacheStorage(); |
79 | 70 | |
80 | | - // $wgContLang = new StubContLang; |
81 | | - $wgUser = new User; |
82 | | - $wgLang = new StubUserLang; |
83 | | - $wgOut = new StubObject( 'wgOut', 'OutputPage' ); |
84 | | - $wgParser = new StubObject( 'wgParser', $wgParserConf['class'], array( $wgParserConf ) ); |
85 | | - $wgRequest = new WebRequest; |
| 71 | + // $tmpGlobals['wgContLang'] = new StubContLang; |
| 72 | + $tmpGlobals['wgUser'] = new User; |
| 73 | + $tmpGlobals['wgLang'] = new StubUserLang; |
| 74 | + $tmpGlobals['wgOut'] = new StubObject( 'wgOut', 'OutputPage' ); |
| 75 | + $tmpGlobals['wgParser'] = new StubObject( 'wgParser', $GLOBALS['wgParserConf']['class'], array( $GLOBALS['wgParserConf'] ) ); |
| 76 | + $tmpGlobals['wgRequest'] = new WebRequest; |
86 | 77 | |
87 | | - $wgMessageCache = new StubObject( 'wgMessageCache', 'MessageCache', |
| 78 | + $tmpGlobals['wgMessageCache'] = new StubObject( 'wgMessageCache', 'MessageCache', |
88 | 79 | array( $messageMemc, $wgUseDatabaseMessages, |
89 | 80 | $wgMsgCacheExpiry ) ); |
90 | | - if ( $wgStyleDirectory === false ) { |
91 | | - $wgStyleDirectory = "$IP/skins"; |
| 81 | + if ( $GLOBALS['wgStyleDirectory'] === false ) { |
| 82 | + $tmpGlobals['wgStyleDirectory'] = "$IP/skins"; |
92 | 83 | } |
93 | 84 | |
| 85 | + |
| 86 | + foreach ( $tmpGlobals as $var => $val ) { |
| 87 | + if ( array_key_exists( $var, $GLOBALS ) ) { |
| 88 | + $this->savedInitialGlobals[$var] = $GLOBALS[$var]; |
| 89 | + } |
| 90 | + |
| 91 | + $GLOBALS[$var] = $val; |
| 92 | + } |
| 93 | + |
| 94 | + $this->savedWeirdGlobals['mw_namespace_protection'] = $wgNamespaceProtection[NS_MEDIAWIKI]; |
| 95 | + $this->savedWeirdGlobals['image_alias'] = $wgNamespaceAliases['Image']; |
| 96 | + $this->savedWeirdGlobals['image_talk_alias'] = $wgNamespaceAliases['Image_talk']; |
| 97 | + |
| 98 | + $wgNamespaceProtection[NS_MEDIAWIKI] = 'editinterface'; |
| 99 | + $wgNamespaceAliases['Image'] = NS_FILE; |
| 100 | + $wgNamespaceAliases['Image_talk'] = NS_FILE_TALK; |
| 101 | + |
94 | 102 | } |
95 | 103 | |
96 | 104 | public function tearDown() { |
| 105 | + |
| 106 | + foreach ( $this->savedInitialGlobals as $var => $val ) { |
| 107 | + $GLOBALS[$var] = $val; |
| 108 | + } |
| 109 | + |
| 110 | + global $wgNamespaceProtection, $wgNamespaceAliases; |
| 111 | + |
| 112 | + $wgNamespaceProtection[NS_MEDIAWIKI] = $this->savedWeirdGlobals['mw_namespace_protection']; |
| 113 | + $wgNamespaceAliases['Image'] = $this->savedWeirdGlobals['image_alias']; |
| 114 | + $wgNamespaceAliases['Image_talk'] = $this->savedWeirdGlobals['image_talk_alias']; |
97 | 115 | } |
98 | 116 | |
99 | 117 | function addDBData() { |
Index: trunk/phase3/tests/TestsAutoLoader.php |
— | — | @@ -4,10 +4,20 @@ |
5 | 5 | $testFolder = dirname( __FILE__ ); |
6 | 6 | |
7 | 7 | $wgAutoloadClasses += array( |
| 8 | + |
| 9 | + //PHPUnit |
8 | 10 | 'MediaWikiTestCase' => "$testFolder/phpunit/MediaWikiTestCase.php", |
9 | 11 | 'MediaWikiPHPUnitCommand' => "$testFolder/phpunit/MediaWikiPHPUnitCommand.php", |
10 | | - 'ApiTestSetup' => "$testFolder/phpunit/includes/api/ApiSetup.php", |
11 | | - 'RandomImageGenerator' => "$testFolder/phpunit/includes/api/RandomImageGenerator.php", |
| 12 | + |
| 13 | + //API |
| 14 | + 'ApiTestSetup' => "$testFolder/phpunit/includes/api/ApiSetup.php", |
| 15 | + 'RandomImageGenerator' => "$testFolder/phpunit/includes/api/RandomImageGenerator.php", |
| 16 | + |
| 17 | + //Parser |
| 18 | + 'ParserTestFileIterator' => "$testFolder/phpunit/includes/parser/NewParserHelpers.php", |
| 19 | + |
| 20 | + |
| 21 | + //Selenium |
12 | 22 | 'SeleniumTestConstants' => "$testFolder/selenium/SeleniumTestConstants.php", |
13 | 23 | ); |
14 | 24 | |