http://www.mediawiki.org/wiki/Special:Code/MediaWiki/74122
Revision: 74122
Author: platonides
Date: 2010-10-01 23:11:21 +0000 (Fri, 01 Oct 2010)
Log Message:
-----------
Revert r74117. Breaks the test. Using an internal request it doesn't fail with
NeedToken, but gives Success instead.
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 22:59:57 UTC (rev 74121)
+++ trunk/phase3/maintenance/tests/phpunit/includes/api/ApiTest.php
2010-10-01 23:11:21 UTC (rev 74122)
@@ -90,36 +90,32 @@
if ( !isset( $wgServer ) ) {
$this->markTestIncomplete( 'This test needs $wgServer
to be set in LocalSettings.php' );
}
- $ret = $this->doApiRequest( array(
- "action" => "login",
- "lgname" => self::$userName,
- "lgpassword" => "bad",
- )
- );
+ $resp = Http::post( self::$apiUrl . "?action=login&format=xml",
+ array( "postData" => array(
+
"lgname" => self::$userName,
+
"lgpassword" => "bad" ) ) );
+ libxml_use_internal_errors( true );
+ $sxe = simplexml_load_string( $resp );
+ $this->assertNotType( "bool", $sxe );
+ $this->assertThat( $sxe, $this->isInstanceOf(
"SimpleXMLElement" ) );
+ $a = $sxe->login[0]->attributes()->result[0];
+ $this->assertEquals( ' result="NeedToken"', $a->asXML() );
- $result = $ret[0];
+ $token = (string)$sxe->login[0]->attributes()->token;
- $this->assertNotType( "bool", $result );
+ $resp = Http::post( self::$apiUrl . "?action=login&format=xml",
+ array( "postData" => array(
+
"lgtoken" => $token,
+
"lgname" => self::$userName,
+
"lgpassword" => "bad" ) ) );
- $a = $result["login"]["result"];
- $this->assertEquals( "NeedToken", $a );
- $token = $result["login"]["token"];
+ $sxe = simplexml_load_string( $resp );
+ $this->assertNotType( "bool", $sxe );
+ $this->assertThat( $sxe, $this->isInstanceOf(
"SimpleXMLElement" ) );
+ $a = $sxe->login[0]->attributes()->result[0];
- $ret = $this->doApiRequest( array(
- "action" => "login",
- "lgtoken" => $token,
- "lgname" => self::$userName,
- "lgpassword" => "bad",
- )
- );
-
- $result = $ret[0];
-
- $this->assertNotType( "bool", $result );
- $a = $result["login"]["result"];
-
- $this->assertEquals( "NeedToken", $a );
+ $this->assertEquals( ' result="NeedToken"', $a->asXML() );
}
function testApiLoginGoodPass() {
@@ -136,6 +132,7 @@
)
);
+ libxml_use_internal_errors( true );
$result = $ret[0];
$this->assertNotType( "bool", $result );
$this->assertNotType( "null", $result["login"] );
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs