r62499 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62498‎ | r62499 | r62500 >
Date:07:10, 15 February 2010
Author:mah
Status:deferred
Tags:
Comment:
follow up r62498 tests for the requireOnlyOneParameter() change
Modified paths:
  • /trunk/phase3/maintenance/tests/ApiTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/tests/ApiTest.php
@@ -2,17 +2,65 @@
33
44 require_once( "ApiSetup.php" );
55
 6+class MockApi extends ApiBase {
 7+ public function execute() {}
 8+ public function getVersion() {}
 9+
 10+ public function __construct() {}
 11+
 12+ public function getAllowedParams() {
 13+ $params = array(
 14+ 'filename' => null,
 15+ 'enablechunks' => false,
 16+ 'sessionkey' => null,
 17+ );
 18+ }
 19+
 20+
 21+}
 22+
 23+
624 class ApiTest extends ApiSetup {
725
826 function setup() {
9 - if($wgServerName == "localhost" || $wgServer == "http://localhost") {
10 - $this->markTestIncomplete('This test needs $wgServerName and $wgServer to '.
11 - 'be set in LocalSettings.php');
12 - }
1327 parent::setup();
1428 }
1529
 30+ function testRequireOnlyOneParameterDefault() {
 31+ $mock = new MockApi();
 32+
 33+ $this->assertEquals(
 34+ null, $mock->requireOnlyOneParameter(array("filename" => "foo.txt",
 35+ "enablechunks" => false), "filename", "enablechunks"));
 36+ }
 37+
 38+ /**
 39+ * @expectedException UsageException
 40+ */
 41+ function testRequireOnlyOneParameterZero() {
 42+ $mock = new MockApi();
 43+
 44+ $this->assertEquals(
 45+ null, $mock->requireOnlyOneParameter(array("filename" => "foo.txt",
 46+ "enablechunks" => 0), "filename", "enablechunks"));
 47+ }
 48+
 49+ /**
 50+ * @expectedException UsageException
 51+ */
 52+ function testRequireOnlyOneParameterTrue() {
 53+ $mock = new MockApi();
 54+
 55+ $this->assertEquals(
 56+ null, $mock->requireOnlyOneParameter(array("filename" => "foo.txt",
 57+ "enablechunks" => true), "filename", "enablechunks"));
 58+ }
 59+
1660 function testApi() {
 61+ if(!isset($wgServername) || !isset($wgServer)) {
 62+ $this->markTestIncomplete('This test needs $wgServerName and $wgServer to '.
 63+ 'be set in LocalSettings.php');
 64+ }
1765 /* Haven't thought about test ordering yet -- but this depends on HttpTest.php */
1866 $resp = Http::get( self::$apiUrl . "?format=xml" );
1967
@@ -23,6 +71,10 @@
2472 }
2573
2674 function testApiLoginNoName() {
 75+ if(!isset($wgServername) || !isset($wgServer)) {
 76+ $this->markTestIncomplete('This test needs $wgServerName and $wgServer to '.
 77+ 'be set in LocalSettings.php');
 78+ }
2779 $resp = Http::post( self::$apiUrl . "?action=login&format=xml",
2880 array( "postData" => array(
2981 "lgname" => "",
@@ -36,6 +88,10 @@
3789 }
3890
3991 function testApiLoginBadPass() {
 92+ if(!isset($wgServername) || !isset($wgServer)) {
 93+ $this->markTestIncomplete('This test needs $wgServerName and $wgServer to '.
 94+ 'be set in LocalSettings.php');
 95+ }
4096 $resp = Http::post( self::$apiUrl . "?action=login&format=xml",
4197 array( "postData" => array(
4298 "lgname" => self::$userName,
@@ -49,6 +105,10 @@
50106 }
51107
52108 function testApiLoginGoodPass() {
 109+ if(!isset($wgServername) || !isset($wgServer)) {
 110+ $this->markTestIncomplete('This test needs $wgServerName and $wgServer to '.
 111+ 'be set in LocalSettings.php');
 112+ }
53113 $resp = Http::post( self::$apiUrl . "?action=login&format=xml",
54114 array( "postData" => array(
55115 "lgname" => self::$userName,
@@ -64,6 +124,10 @@
65125 function testApiGotCookie() {
66126 global $wgScriptPath, $wgServerName;
67127
 128+ if(!isset($wgServername) || !isset($wgServer)) {
 129+ $this->markTestIncomplete('This test needs $wgServerName and $wgServer to '.
 130+ 'be set in LocalSettings.php');
 131+ }
68132 $req = HttpRequest::factory( self::$apiUrl . "?action=login&format=xml",
69133 array( "method" => "POST",
70134 "postData" => array( "lgname" => self::$userName,
@@ -83,6 +147,10 @@
84148 function testApiListPages(CookieJar $cj) {
85149 $this->markTestIncomplete("Not done with this yet");
86150
 151+ if($wgServerName == "localhost" || $wgServer == "http://localhost") {
 152+ $this->markTestIncomplete('This test needs $wgServerName and $wgServer to '.
 153+ 'be set in LocalSettings.php');
 154+ }
87155 $req = HttpRequest::factory( self::$apiUrl . "?action=query&format=xml&prop=revisions&".
88156 "titles=Main%20Page&rvprop=timestamp|user|comment|content" );
89157 $req->setCookieJar($cj);

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r62498follow up r62353 Make ApiBase::requireOnlyOneParameter() accept parameters th...mah07:06, 15 February 2010

Status & tagging log