From: Sam Reed Date: Fri, 1 Oct 2010 21:50:52 +0000 (+0000) Subject: Switch testApiLoginGoodPass to use doApiRequest X-Git-Tag: 1.31.0-rc.0~34695 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/pie.php?a=commitdiff_plain;h=4a765f76f9c07769673b237980d663e49418b3d5;p=lhc%2Fweb%2Fwiklou.git Switch testApiLoginGoodPass to use doApiRequest Submitting for IRC sanity check :D --- diff --git a/maintenance/tests/phpunit/includes/api/ApiTest.php b/maintenance/tests/phpunit/includes/api/ApiTest.php index b520032f99..178e6ed302 100644 --- a/maintenance/tests/phpunit/includes/api/ApiTest.php +++ b/maintenance/tests/phpunit/includes/api/ApiTest.php @@ -124,36 +124,37 @@ class ApiTest extends ApiTestSetup { 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 @@ class ApiTest extends ApiTestSetup { $this->assertNotEquals( '', $serializedCookie ); $this->assertRegexp( '/_session=[^;]*; .*UserID=[0-9]*; .*UserName=' . self::$userName . '; .*Token=/', $serializedCookie ); - return $cj; }