From: Sam Reed Date: Fri, 1 Oct 2010 22:27:56 +0000 (+0000) Subject: Fixup testApiLoginBadPass per r74113, still failing, it's checking for "NeedToken... X-Git-Tag: 1.31.0-rc.0~34692 X-Git-Url: http://git.cyclocoop.org/ecrire?a=commitdiff_plain;h=73d5f876a473e0c264e0f20fb4ede5ec2f00e2e0;p=lhc%2Fweb%2Fwiklou.git Fixup testApiLoginBadPass per r74113, still failing, it's checking for "NeedToken" at the end of the test, but "success" is being returned, which seems wrong to me... --- diff --git a/maintenance/tests/phpunit/includes/api/ApiTest.php b/maintenance/tests/phpunit/includes/api/ApiTest.php index 178e6ed302..6579fe3194 100644 --- a/maintenance/tests/phpunit/includes/api/ApiTest.php +++ b/maintenance/tests/phpunit/includes/api/ApiTest.php @@ -90,32 +90,36 @@ class ApiTest extends ApiTestSetup { if ( !isset( $wgServer ) ) { $this->markTestIncomplete( 'This test needs $wgServer to be set in LocalSettings.php' ); } - $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() ); + $ret = $this->doApiRequest( array( + "action" => "login", + "lgname" => self::$userName, + "lgpassword" => "bad", + ) + ); - $token = (string)$sxe->login[0]->attributes()->token; + $result = $ret[0]; - $resp = Http::post( self::$apiUrl . "?action=login&format=xml", - array( "postData" => array( - "lgtoken" => $token, - "lgname" => self::$userName, - "lgpassword" => "bad" ) ) ); + $this->assertNotType( "bool", $result ); + $a = $result["login"]["result"]; + $this->assertEquals( "NeedToken", $a ); - $sxe = simplexml_load_string( $resp ); - $this->assertNotType( "bool", $sxe ); - $this->assertThat( $sxe, $this->isInstanceOf( "SimpleXMLElement" ) ); - $a = $sxe->login[0]->attributes()->result[0]; + $token = $result["login"]["token"]; - $this->assertEquals( ' result="NeedToken"', $a->asXML() ); + $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 ); } function testApiLoginGoodPass() { @@ -132,7 +136,6 @@ class ApiTest extends ApiTestSetup { ) ); - libxml_use_internal_errors( true ); $result = $ret[0]; $this->assertNotType( "bool", $result ); $this->assertNotType( "null", $result["login"] );