http://www.mediawiki.org/wiki/Special:Code/MediaWiki/74113
Revision: 74113
Author: reedy
Date: 2010-10-01 21:50:52 +0000 (Fri, 01 Oct 2010)
Log Message:
-----------
Switch testApiLoginGoodPass to use doApiRequest
Submitting for IRC sanity check :D
Modified Paths:
--------------
trunk/phase3/maintenance/tests/phpunit/includes/api/ApiTest.php
Modified: trunk/phase3/maintenance/tests/phpunit/includes/api/ApiTest.php
===================================================================
--- trunk/phase3/maintenance/tests/phpunit/includes/api/ApiTest.php
2010-10-01 21:50:32 UTC (rev 74112)
+++ trunk/phase3/maintenance/tests/phpunit/includes/api/ApiTest.php
2010-10-01 21:50:52 UTC (rev 74113)
@@ -124,36 +124,37 @@
if ( !isset( $wgServer ) ) {
$this->markTestIncomplete( 'This test needs $wgServer
to be set in LocalSettings.php' );
}
- $req = HttpRequest::factory( self::$apiUrl .
"?action=login&format=xml",
- array( "method" => "POST",
- "postData" => array(
- "lgname" => self::$userName,
- "lgpassword" => self::$passWord ) ) );
- $req->execute();
+ $ret = $this->doApiRequest( array(
+ "action" => "login",
+ "lgname" => self::$userName,
+ "lgpassword" => self::$passWord,
+ )
+ );
+
libxml_use_internal_errors( true );
- $sxe = simplexml_load_string( $req->getContent() );
- $this->assertNotType( "bool", $sxe );
- $this->assertThat( $sxe, $this->isInstanceOf(
"SimpleXMLElement" ) );
- $this->assertNotType( "null", $sxe->login[0] );
+ $result = $ret[0];
+ $this->assertNotType( "bool", $result );
+ $this->assertNotType( "null", $result["login"] );
- $a = $sxe->login[0]->attributes()->result[0];
- $this->assertEquals( ' result="NeedToken"', $a->asXML() );
- $token = (string)$sxe->login[0]->attributes()->token;
+ $a = $result["login"]["result"];
+ $this->assertEquals( "NeedToken", $a );
+ $token = $result["login"]["token"];
- $req->setData( array(
+ $ret = $this->doApiRequest( array(
+ "action" => "login",
"lgtoken" => $token,
"lgname" => self::$userName,
- "lgpassword" => self::$passWord ) );
- $req->execute();
+ "lgpassword" => self::$passWord,
+ )
+ );
- $sxe = simplexml_load_string( $req->getContent() );
+ $result = $ret[0];
- $this->assertNotType( "bool", $sxe );
- $this->assertThat( $sxe, $this->isInstanceOf(
"SimpleXMLElement" ) );
- $a = $sxe->login[0]->attributes()->result[0];
+ $this->assertNotType( "bool", $result );
+ $a = $result["login"]["result"];
- $this->assertEquals( ' result="Success"', $a->asXML() );
+ $this->assertEquals( "Success", $a );
}
function testApiGotCookie() {
@@ -192,7 +193,6 @@
$this->assertNotEquals( '', $serializedCookie );
$this->assertRegexp( '/_session=[^;]*; .*UserID=[0-9]*;
.*UserName=' . self::$userName . '; .*Token=/', $serializedCookie );
-
return $cj;
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs