r61936 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61935‎ | r61936 | r61937 >
Date:16:27, 3 February 2010
Author:mah
Status:deferred
Tags:
Comment:
follow-up r61917 - stylize for coding conventions
Modified paths:
  • /trunk/phase3/tests/MediaWikiAPITest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/MediaWikiAPITest.php
@@ -1,6 +1,6 @@
22 <?php
33
4 -require_once("MediaWikiAPI_TestCase.php");
 4+require_once( "MediaWikiAPI_TestCase.php" );
55
66 class MediaWikiAPITest extends MediaWikiAPI_TestCase {
77
@@ -10,49 +10,49 @@
1111
1212 function testApi() {
1313 /* Haven't thought about test ordering yet -- but this depends on HttpTest.php */
14 - $resp = Http::get(self::$apiUrl."?format=xml");
 14+ $resp = Http::get( self::$apiUrl . "?format=xml" );
1515
16 - libxml_use_internal_errors(true);
17 - $sxe = simplexml_load_string($resp);
18 - $this->assertNotType("bool", $sxe);
19 - $this->assertThat($sxe, $this->isInstanceOf("SimpleXMLElement"));
 16+ libxml_use_internal_errors( true );
 17+ $sxe = simplexml_load_string( $resp );
 18+ $this->assertNotType( "bool", $sxe );
 19+ $this->assertThat( $sxe, $this->isInstanceOf( "SimpleXMLElement" ) );
2020 }
2121
2222 function testApiLoginNoName() {
23 - $resp = Http::post(self::$apiUrl."?action=login&format=xml",
24 - array("postData" => array(
25 - "lgname" => "",
26 - "lgpassword" => self::$passWord)));
27 - libxml_use_internal_errors(true);
28 - $sxe = simplexml_load_string($resp);
29 - $this->assertNotType("bool", $sxe);
30 - $this->assertThat($sxe, $this->isInstanceOf("SimpleXMLElement"));
 23+ $resp = Http::post( self::$apiUrl . "?action=login&format=xml",
 24+ array( "postData" => array(
 25+ "lgname" => "",
 26+ "lgpassword" => self::$passWord ) ) );
 27+ libxml_use_internal_errors( true );
 28+ $sxe = simplexml_load_string( $resp );
 29+ $this->assertNotType( "bool", $sxe );
 30+ $this->assertThat( $sxe, $this->isInstanceOf( "SimpleXMLElement" ) );
3131 $a = $sxe->login[0]->attributes()->result;
3232 $this->assertEquals( ' result="NoName"', $a->asXML() );
3333 }
3434
3535 function testApiLoginBadPass() {
36 - $resp = Http::post(self::$apiUrl."?action=login&format=xml",
37 - array("postData" => array(
38 - "lgname" => self::$userName,
39 - "lgpassword" => "bad")));
40 - libxml_use_internal_errors(true);
41 - $sxe = simplexml_load_string($resp);
42 - $this->assertNotType("bool", $sxe);
43 - $this->assertThat($sxe, $this->isInstanceOf("SimpleXMLElement"));
 36+ $resp = Http::post( self::$apiUrl . "?action=login&format=xml",
 37+ array( "postData" => array(
 38+ "lgname" => self::$userName,
 39+ "lgpassword" => "bad" ) ) );
 40+ libxml_use_internal_errors( true );
 41+ $sxe = simplexml_load_string( $resp );
 42+ $this->assertNotType( "bool", $sxe );
 43+ $this->assertThat( $sxe, $this->isInstanceOf( "SimpleXMLElement" ) );
4444 $a = $sxe->login[0]->attributes()->result;
4545 $this->assertEquals( ' result="WrongPass"', $a->asXML() );
4646 }
4747
4848 function testApiLoginGoodPass() {
49 - $resp = Http::post(self::$apiUrl."?action=login&format=xml",
50 - array("postData" => array(
51 - "lgname" => self::$userName,
52 - "lgpassword" => self::$passWord)));
53 - libxml_use_internal_errors(true);
54 - $sxe = simplexml_load_string($resp);
55 - $this->assertNotType("bool", $sxe);
56 - $this->assertThat($sxe, $this->isInstanceOf("SimpleXMLElement"));
 49+ $resp = Http::post( self::$apiUrl . "?action=login&format=xml",
 50+ array( "postData" => array(
 51+ "lgname" => self::$userName,
 52+ "lgpassword" => self::$passWord ) ) );
 53+ libxml_use_internal_errors( true );
 54+ $sxe = simplexml_load_string( $resp );
 55+ $this->assertNotType( "bool", $sxe );
 56+ $this->assertThat( $sxe, $this->isInstanceOf( "SimpleXMLElement" ) );
5757 $a = $sxe->login[0]->attributes()->result;
5858 $this->assertEquals( ' result="Success"', $a->asXML() );
5959 }
@@ -60,15 +60,15 @@
6161 function testApiGotCookie() {
6262 global $wgScriptPath, $wgServerName;
6363
64 - $req = HttpRequest::factory(self::$apiUrl."?action=login&format=xml",
65 - array("method" => "POST",
 64+ $req = HttpRequest::factory( self::$apiUrl . "?action=login&format=xml",
 65+ array( "method" => "POST",
6666 "postData" => array(
6767 "lgname" => self::$userName,
68 - "lgpassword" => self::$passWord)));
 68+ "lgpassword" => self::$passWord ) ) );
6969 $req->execute();
7070 $cj = $req->getCookieJar();
7171
72 - $this->assertRegexp( '/_session=[^;]*; .*UserID=[0-9]*; .*UserName='.self::$userName.'; .*Token=/',
73 - $cj->serializeToHttpRequest($wgScriptPath, $wgServerName) );
 72+ $this->assertRegexp( '/_session=[^;]*; .*UserID=[0-9]*; .*UserName=' . self::$userName . '; .*Token=/',
 73+ $cj->serializeToHttpRequest( $wgScriptPath, $wgServerName ) );
7474 }
7575 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r61917Add preliminary API tests. Next step: UploadChunks API testing.mah07:45, 3 February 2010

Status & tagging log