r74113 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74112‎ | r74113 | r74114 >
Date:21:50, 1 October 2010
Author:reedy
Status:deferred (Comments)
Tags:
Comment:
Switch testApiLoginGoodPass to use doApiRequest

Submitting for IRC sanity check :D
Modified paths:
  • /trunk/phase3/maintenance/tests/phpunit/includes/api/ApiTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/tests/phpunit/includes/api/ApiTest.php
@@ -124,36 +124,37 @@
125125 if ( !isset( $wgServer ) ) {
126126 $this->markTestIncomplete( 'This test needs $wgServer to be set in LocalSettings.php' );
127127 }
128 - $req = HttpRequest::factory( self::$apiUrl . "?action=login&format=xml",
129 - array( "method" => "POST",
130 - "postData" => array(
131 - "lgname" => self::$userName,
132 - "lgpassword" => self::$passWord ) ) );
133 - $req->execute();
134128
 129+ $ret = $this->doApiRequest( array(
 130+ "action" => "login",
 131+ "lgname" => self::$userName,
 132+ "lgpassword" => self::$passWord,
 133+ )
 134+ );
 135+
135136 libxml_use_internal_errors( true );
136 - $sxe = simplexml_load_string( $req->getContent() );
137 - $this->assertNotType( "bool", $sxe );
138 - $this->assertThat( $sxe, $this->isInstanceOf( "SimpleXMLElement" ) );
139 - $this->assertNotType( "null", $sxe->login[0] );
 137+ $result = $ret[0];
 138+ $this->assertNotType( "bool", $result );
 139+ $this->assertNotType( "null", $result["login"] );
140140
141 - $a = $sxe->login[0]->attributes()->result[0];
142 - $this->assertEquals( ' result="NeedToken"', $a->asXML() );
143 - $token = (string)$sxe->login[0]->attributes()->token;
 141+ $a = $result["login"]["result"];
 142+ $this->assertEquals( "NeedToken", $a );
 143+ $token = $result["login"]["token"];
144144
145 - $req->setData( array(
 145+ $ret = $this->doApiRequest( array(
 146+ "action" => "login",
146147 "lgtoken" => $token,
147148 "lgname" => self::$userName,
148 - "lgpassword" => self::$passWord ) );
149 - $req->execute();
 149+ "lgpassword" => self::$passWord,
 150+ )
 151+ );
150152
151 - $sxe = simplexml_load_string( $req->getContent() );
 153+ $result = $ret[0];
152154
153 - $this->assertNotType( "bool", $sxe );
154 - $this->assertThat( $sxe, $this->isInstanceOf( "SimpleXMLElement" ) );
155 - $a = $sxe->login[0]->attributes()->result[0];
 155+ $this->assertNotType( "bool", $result );
 156+ $a = $result["login"]["result"];
156157
157 - $this->assertEquals( ' result="Success"', $a->asXML() );
 158+ $this->assertEquals( "Success", $a );
158159 }
159160
160161 function testApiGotCookie() {
@@ -192,7 +193,6 @@
193194 $this->assertNotEquals( '', $serializedCookie );
194195 $this->assertRegexp( '/_session=[^;]*; .*UserID=[0-9]*; .*UserName=' . self::$userName . '; .*Token=/', $serializedCookie );
195196
196 -
197197 return $cj;
198198 }
199199

Follow-up revisions

RevisionCommit summaryAuthorDate
r74117Fixup testApiLoginBadPass per r74113, still failing, it's checking for "NeedT...reedy22:27, 1 October 2010

Comments

#Comment by Reedy (talk | contribs)   22:00, 1 October 2010

I'm guessing

libxml_use_internal_errors( true );

is superflouous

#Comment by 😂 (talk | contribs)   01:06, 8 October 2010

Yes.

Status & tagging log