r79375 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79374‎ | r79375 | r79376 >
Date:21:40, 31 December 2010
Author:soxred93
Status:ok
Tags:
Comment:
-If $this->db does not exist, skip destroying the DB
-Fix ApiTest errors due to DB rewrite
Modified paths:
  • /trunk/phase3/tests/phpunit/MediaWikiTestCase.php (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/api/ApiSetup.php (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/api/ApiTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/MediaWikiTestCase.php
@@ -132,6 +132,10 @@
133133 //Temporary tables seem to be broken ATM, delete anyway
134134 }
135135
 136+ if( is_null( $this->db ) ) {
 137+ return;
 138+ }
 139+
136140 if( $this->db->getType() == 'oracle' ) {
137141 $tables = $this->db->listTables( 'ut_', __METHOD__ );
138142 }
Index: trunk/phase3/tests/phpunit/includes/api/ApiTest.php
@@ -79,7 +79,7 @@
8080 */
8181 function testApiLoginNoName() {
8282 $data = $this->doApiRequest( array( 'action' => 'login',
83 - 'lgname' => '', 'lgpassword' => self::$user->password,
 83+ 'lgname' => '', 'lgpassword' => $this->user->password,
8484 ) );
8585 $this->assertEquals( 'NoName', $data[0]['login']['result'] );
8686 }
@@ -87,7 +87,7 @@
8888 function testApiLoginBadPass() {
8989 global $wgServer;
9090
91 - $user = self::$user;
 91+ $user = $this->user;
9292
9393 if ( !isset( $wgServer ) ) {
9494 $this->markTestIncomplete( 'This test needs $wgServer to be set in LocalSettings.php' );
@@ -130,7 +130,7 @@
131131 $this->markTestIncomplete( 'This test needs $wgServer to be set in LocalSettings.php' );
132132 }
133133
134 - $user = self::$user;
 134+ $user = $this->user;
135135
136136 $ret = $this->doApiRequest( array(
137137 "action" => "login",
@@ -174,8 +174,8 @@
175175 $req = MWHttpRequest::factory( self::$apiUrl . "?action=login&format=xml",
176176 array( "method" => "POST",
177177 "postData" => array(
178 - "lgname" => self::$user->userName,
179 - "lgpassword" => self::$user->password ) ) );
 178+ "lgname" => $this->user->userName,
 179+ "lgpassword" => $this->user->password ) ) );
180180 $req->execute();
181181
182182 libxml_use_internal_errors( true );
@@ -190,8 +190,8 @@
191191
192192 $req->setData( array(
193193 "lgtoken" => $token,
194 - "lgname" => self::$user->userName,
195 - "lgpassword" => self::$user->password ) );
 194+ "lgname" => $this->user->userName,
 195+ "lgpassword" => $this->user->password ) );
196196 $req->execute();
197197
198198 $cj = $req->getCookieJar();
@@ -199,7 +199,7 @@
200200 $this->assertNotEquals( false, $serverName );
201201 $serializedCookie = $cj->serializeToHttpRequest( $wgScriptPath, $serverName );
202202 $this->assertNotEquals( '', $serializedCookie );
203 - $this->assertRegexp( '/_session=[^;]*; .*UserID=[0-9]*; .*UserName=' . self::$user->userName . '; .*Token=/', $serializedCookie );
 203+ $this->assertRegexp( '/_session=[^;]*; .*UserID=[0-9]*; .*UserName=' . $this->user->userName . '; .*Token=/', $serializedCookie );
204204
205205 return $cj;
206206 }
Index: trunk/phase3/tests/phpunit/includes/api/ApiSetup.php
@@ -1,8 +1,8 @@
22 <?php
33
44 abstract class ApiTestSetup extends MediaWikiTestCase {
5 - protected static $user;
6 - protected static $sysopUser;
 5+ protected $user;
 6+ protected $sysopUser;
77 protected static $apiUrl;
88
99 function setUp() {
@@ -14,7 +14,7 @@
1515 $wgContLang = Language::factory( 'en' );
1616 $wgAuth = new StubObject( 'wgAuth', 'AuthPlugin' );
1717 $wgRequest = new FauxRequest( array() );
18 - self::setupUser();
 18+ $this->setupUser();
1919 }
2020
2121 protected function doApiRequest( $params, $data = null ) {
@@ -31,13 +31,13 @@
3232 return $data;
3333 }
3434
35 - static function setupUser() {
36 - if ( self::$user == null || self::$sysopUser == null ) {
37 - self::$user = new UserWrapper( 'User for MediaWiki automated tests', User::randomPassword() );
38 - self::$sysopUser = new UserWrapper( 'Sysop for MediaWiki automated tests', User::randomPassword(), 'sysop' );
 35+ function setupUser() {
 36+ if ( $this->user == null || $this->sysopUser == null ) {
 37+ $this->user = new UserWrapper( 'User for MediaWiki automated tests', User::randomPassword() );
 38+ $this->sysopUser = new UserWrapper( 'Sysop for MediaWiki automated tests', User::randomPassword(), 'sysop' );
3939 }
4040
41 - $GLOBALS['wgUser'] = self::$sysopUser->user;
 41+ $GLOBALS['wgUser'] = $this->sysopUser->user;
4242 }
4343 }
4444

Status & tagging log