Index: trunk/phase3/tests/MediaWikiAPITest.php |
— | — | @@ -1,6 +1,6 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | | -require_once("MediaWikiAPI_TestCase.php"); |
| 4 | +require_once( "MediaWikiAPI_TestCase.php" ); |
5 | 5 | |
6 | 6 | class MediaWikiAPITest extends MediaWikiAPI_TestCase { |
7 | 7 | |
— | — | @@ -10,49 +10,49 @@ |
11 | 11 | |
12 | 12 | function testApi() { |
13 | 13 | /* 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" ); |
15 | 15 | |
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" ) ); |
20 | 20 | } |
21 | 21 | |
22 | 22 | 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" ) ); |
31 | 31 | $a = $sxe->login[0]->attributes()->result; |
32 | 32 | $this->assertEquals( ' result="NoName"', $a->asXML() ); |
33 | 33 | } |
34 | 34 | |
35 | 35 | 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" ) ); |
44 | 44 | $a = $sxe->login[0]->attributes()->result; |
45 | 45 | $this->assertEquals( ' result="WrongPass"', $a->asXML() ); |
46 | 46 | } |
47 | 47 | |
48 | 48 | 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" ) ); |
57 | 57 | $a = $sxe->login[0]->attributes()->result; |
58 | 58 | $this->assertEquals( ' result="Success"', $a->asXML() ); |
59 | 59 | } |
— | — | @@ -60,15 +60,15 @@ |
61 | 61 | function testApiGotCookie() { |
62 | 62 | global $wgScriptPath, $wgServerName; |
63 | 63 | |
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", |
66 | 66 | "postData" => array( |
67 | 67 | "lgname" => self::$userName, |
68 | | - "lgpassword" => self::$passWord))); |
| 68 | + "lgpassword" => self::$passWord ) ) ); |
69 | 69 | $req->execute(); |
70 | 70 | $cj = $req->getCookieJar(); |
71 | 71 | |
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 ) ); |
74 | 74 | } |
75 | 75 | } |