r74117 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74116‎ | r74117 | r74118 >
Date:22:27, 1 October 2010
Author:reedy
Status:deferred
Tags:
Comment:
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...
Modified paths:
  • /trunk/phase3/maintenance/tests/phpunit/includes/api/ApiTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/tests/phpunit/includes/api/ApiTest.php
@@ -90,32 +90,36 @@
9191 if ( !isset( $wgServer ) ) {
9292 $this->markTestIncomplete( 'This test needs $wgServer to be set in LocalSettings.php' );
9393 }
94 - $resp = Http::post( self::$apiUrl . "?action=login&format=xml",
95 - array( "postData" => array(
96 - "lgname" => self::$userName,
97 - "lgpassword" => "bad" ) ) );
98 - libxml_use_internal_errors( true );
99 - $sxe = simplexml_load_string( $resp );
100 - $this->assertNotType( "bool", $sxe );
101 - $this->assertThat( $sxe, $this->isInstanceOf( "SimpleXMLElement" ) );
102 - $a = $sxe->login[0]->attributes()->result[0];
103 - $this->assertEquals( ' result="NeedToken"', $a->asXML() );
 94+ $ret = $this->doApiRequest( array(
 95+ "action" => "login",
 96+ "lgname" => self::$userName,
 97+ "lgpassword" => "bad",
 98+ )
 99+ );
104100
105 - $token = (string)$sxe->login[0]->attributes()->token;
 101+ $result = $ret[0];
106102
107 - $resp = Http::post( self::$apiUrl . "?action=login&format=xml",
108 - array( "postData" => array(
109 - "lgtoken" => $token,
110 - "lgname" => self::$userName,
111 - "lgpassword" => "bad" ) ) );
 103+ $this->assertNotType( "bool", $result );
112104
 105+ $a = $result["login"]["result"];
 106+ $this->assertEquals( "NeedToken", $a );
113107
114 - $sxe = simplexml_load_string( $resp );
115 - $this->assertNotType( "bool", $sxe );
116 - $this->assertThat( $sxe, $this->isInstanceOf( "SimpleXMLElement" ) );
117 - $a = $sxe->login[0]->attributes()->result[0];
 108+ $token = $result["login"]["token"];
118109
119 - $this->assertEquals( ' result="NeedToken"', $a->asXML() );
 110+ $ret = $this->doApiRequest( array(
 111+ "action" => "login",
 112+ "lgtoken" => $token,
 113+ "lgname" => self::$userName,
 114+ "lgpassword" => "bad",
 115+ )
 116+ );
 117+
 118+ $result = $ret[0];
 119+
 120+ $this->assertNotType( "bool", $result );
 121+ $a = $result["login"]["result"];
 122+
 123+ $this->assertEquals( "NeedToken", $a );
120124 }
121125
122126 function testApiLoginGoodPass() {
@@ -132,7 +136,6 @@
133137 )
134138 );
135139
136 - libxml_use_internal_errors( true );
137140 $result = $ret[0];
138141 $this->assertNotType( "bool", $result );
139142 $this->assertNotType( "null", $result["login"] );

Follow-up revisions

RevisionCommit summaryAuthorDate
r74122Revert r74117. Breaks the test. Using an internal request it doesn't fail wit...platonides23:11, 1 October 2010
r74213Revert r74122, making r74117 live again...reedy15:24, 3 October 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r74113Switch testApiLoginGoodPass to use doApiRequest...reedy21:50, 1 October 2010

Status & tagging log