From: Platonides Date: Fri, 1 Oct 2010 23:11:21 +0000 (+0000) Subject: Revert r74117. Breaks the test. Using an internal request it doesn't fail with NeedTo... X-Git-Tag: 1.31.0-rc.0~34688 X-Git-Url: http://git.cyclocoop.org//%22javascript:ModifierStyle%28%27%22.%24id.%22%27%29/%22?a=commitdiff_plain;h=acb2e5aea58250c325bebe02e5dea18af10a1972;p=lhc%2Fweb%2Fwiklou.git Revert r74117. Breaks the test. Using an internal request it doesn't fail with NeedToken, but gives Success instead. --- diff --git a/maintenance/tests/phpunit/includes/api/ApiTest.php b/maintenance/tests/phpunit/includes/api/ApiTest.php index 6579fe3194..178e6ed302 100644 --- a/maintenance/tests/phpunit/includes/api/ApiTest.php +++ b/maintenance/tests/phpunit/includes/api/ApiTest.php @@ -90,36 +90,32 @@ class ApiTest extends ApiTestSetup { 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", - ) - ); - - $result = $ret[0]; - - $this->assertNotType( "bool", $result ); - - $a = $result["login"]["result"]; - $this->assertEquals( "NeedToken", $a ); + $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() ); - $token = $result["login"]["token"]; + $token = (string)$sxe->login[0]->attributes()->token; - $ret = $this->doApiRequest( array( - "action" => "login", - "lgtoken" => $token, - "lgname" => self::$userName, - "lgpassword" => "bad", - ) - ); + $resp = Http::post( self::$apiUrl . "?action=login&format=xml", + array( "postData" => array( + "lgtoken" => $token, + "lgname" => self::$userName, + "lgpassword" => "bad" ) ) ); - $result = $ret[0]; - $this->assertNotType( "bool", $result ); - $a = $result["login"]["result"]; + $sxe = simplexml_load_string( $resp ); + $this->assertNotType( "bool", $sxe ); + $this->assertThat( $sxe, $this->isInstanceOf( "SimpleXMLElement" ) ); + $a = $sxe->login[0]->attributes()->result[0]; - $this->assertEquals( "NeedToken", $a ); + $this->assertEquals( ' result="NeedToken"', $a->asXML() ); } function testApiLoginGoodPass() { @@ -136,6 +132,7 @@ class ApiTest extends ApiTestSetup { ) ); + libxml_use_internal_errors( true ); $result = $ret[0]; $this->assertNotType( "bool", $result ); $this->assertNotType( "null", $result["login"] );