summaryrefslogtreecommitdiff
path: root/tests/phpunit/includes/api/ApiTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/phpunit/includes/api/ApiTest.php')
-rw-r--r--tests/phpunit/includes/api/ApiTest.php47
1 files changed, 20 insertions, 27 deletions
diff --git a/tests/phpunit/includes/api/ApiTest.php b/tests/phpunit/includes/api/ApiTest.php
index 22770288..472f8c4a 100644
--- a/tests/phpunit/includes/api/ApiTest.php
+++ b/tests/phpunit/includes/api/ApiTest.php
@@ -7,7 +7,7 @@
*/
class ApiTest extends ApiTestCase {
- function testRequireOnlyOneParameterDefault() {
+ public function testRequireOnlyOneParameterDefault() {
$mock = new MockApi();
$this->assertEquals(
@@ -18,7 +18,7 @@ class ApiTest extends ApiTestCase {
/**
* @expectedException UsageException
*/
- function testRequireOnlyOneParameterZero() {
+ public function testRequireOnlyOneParameterZero() {
$mock = new MockApi();
$this->assertEquals(
@@ -29,7 +29,7 @@ class ApiTest extends ApiTestCase {
/**
* @expectedException UsageException
*/
- function testRequireOnlyOneParameterTrue() {
+ public function testRequireOnlyOneParameterTrue() {
$mock = new MockApi();
$this->assertEquals(
@@ -43,7 +43,7 @@ class ApiTest extends ApiTestCase {
*
* @expectedException UsageException
*/
- function testApi() {
+ public function testApi() {
$api = new ApiMain(
new FauxRequest( array( 'action' => 'help', 'format' => 'xml' ) )
);
@@ -61,14 +61,14 @@ class ApiTest extends ApiTestCase {
/**
* Test result of attempted login with an empty username
*/
- function testApiLoginNoName() {
+ public function testApiLoginNoName() {
$data = $this->doApiRequest( array( 'action' => 'login',
'lgname' => '', 'lgpassword' => self::$users['sysop']->password,
) );
$this->assertEquals( 'NoName', $data[0]['login']['result'] );
}
- function testApiLoginBadPass() {
+ public function testApiLoginBadPass() {
global $wgServer;
$user = self::$users['sysop'];
@@ -81,8 +81,7 @@ class ApiTest extends ApiTestCase {
"action" => "login",
"lgname" => $user->username,
"lgpassword" => "bad",
- )
- );
+ ) );
$result = $ret[0];
@@ -110,7 +109,7 @@ class ApiTest extends ApiTestCase {
$this->assertEquals( "WrongPass", $a );
}
- function testApiLoginGoodPass() {
+ public function testApiLoginGoodPass() {
global $wgServer;
if ( !isset( $wgServer ) ) {
@@ -136,7 +135,7 @@ class ApiTest extends ApiTestCase {
$token = $result["login"]["token"];
$ret = $this->doApiRequest(
- array(
+ array(
"action" => "login",
"lgtoken" => $token,
"lgname" => $user->username,
@@ -156,7 +155,7 @@ class ApiTest extends ApiTestCase {
/**
* @group Broken
*/
- function testApiGotCookie() {
+ public function testApiGotCookie() {
$this->markTestIncomplete( "The server can't do external HTTP requests, and the internal one won't give cookies" );
global $wgServer, $wgScriptPath;
@@ -202,7 +201,7 @@ class ApiTest extends ApiTestCase {
return $cj;
}
- function testRunLogin() {
+ public function testRunLogin() {
$sysopUser = self::$users['sysop'];
$data = $this->doApiRequest( array(
'action' => 'login',
@@ -228,39 +227,33 @@ class ApiTest extends ApiTestCase {
return $data;
}
- function testGettingToken() {
+ public function testGettingToken() {
foreach ( self::$users as $user ) {
$this->runTokenTest( $user );
}
}
function runTokenTest( $user ) {
- $data = $this->getTokenList( $user );
-
- $this->assertArrayHasKey( 'query', $data[0] );
- $this->assertArrayHasKey( 'pages', $data[0]['query'] );
- $keys = array_keys( $data[0]['query']['pages'] );
- $key = array_pop( $keys );
+ $tokens = $this->getTokenList( $user );
$rights = $user->user->getRights();
- $this->assertArrayHasKey( $key, $data[0]['query']['pages'] );
- $this->assertArrayHasKey( 'edittoken', $data[0]['query']['pages'][$key] );
- $this->assertArrayHasKey( 'movetoken', $data[0]['query']['pages'][$key] );
+ $this->assertArrayHasKey( 'edittoken', $tokens );
+ $this->assertArrayHasKey( 'movetoken', $tokens );
if ( isset( $rights['delete'] ) ) {
- $this->assertArrayHasKey( 'deletetoken', $data[0]['query']['pages'][$key] );
+ $this->assertArrayHasKey( 'deletetoken', $tokens );
}
if ( isset( $rights['block'] ) ) {
- $this->assertArrayHasKey( 'blocktoken', $data[0]['query']['pages'][$key] );
- $this->assertArrayHasKey( 'unblocktoken', $data[0]['query']['pages'][$key] );
+ $this->assertArrayHasKey( 'blocktoken', $tokens );
+ $this->assertArrayHasKey( 'unblocktoken', $tokens );
}
if ( isset( $rights['protect'] ) ) {
- $this->assertArrayHasKey( 'protecttoken', $data[0]['query']['pages'][$key] );
+ $this->assertArrayHasKey( 'protecttoken', $tokens );
}
- return $data;
+ return $tokens;
}
}