http://www.mediawiki.org/wiki/Special:Code/MediaWiki/73921

Revision: 73921
Author:   demon
Date:     2010-09-28 18:13:42 +0000 (Tue, 28 Sep 2010)

Log Message:
-----------
Unify setUp/tearDown in ApiSetup, rather than duplicating in ApiWatchTest. Also 
fix some errors with not passing an array reference that were being suppressed 
(but silently work, yay PHP)

Modified Paths:
--------------
    trunk/phase3/maintenance/tests/phpunit/includes/api/ApiSetup.php
    trunk/phase3/maintenance/tests/phpunit/includes/api/ApiWatchTest.php

Modified: trunk/phase3/maintenance/tests/phpunit/includes/api/ApiSetup.php
===================================================================
--- trunk/phase3/maintenance/tests/phpunit/includes/api/ApiSetup.php    
2010-09-28 17:20:32 UTC (rev 73920)
+++ trunk/phase3/maintenance/tests/phpunit/includes/api/ApiSetup.php    
2010-09-28 18:13:42 UTC (rev 73921)
@@ -6,11 +6,11 @@
        protected static $user;
        protected static $apiUrl;
 
-       function setup() {
+       function setUp() {
                global $wgServer, $wgContLang, $wgAuth, $wgScriptPath,
                        $wgScriptExtension, $wgMemc, $wgRequest;
 
-               self::$apiUrl = $wgServer . $wgScriptPath . "/api" . 
$wgScriptExtension;
+               self::$apiUrl = $wgServer . wfScript( 'api' );
 
                $wgMemc = new FakeMemCachedClient;
                $wgContLang = Language::factory( 'en' );
@@ -36,4 +36,9 @@
                
                $GLOBALS['wgUser'] = self::$user;
        }
+
+       function tearDown() {
+               global $wgMemc;
+               $wgMemc = null;
+       }
 }

Modified: trunk/phase3/maintenance/tests/phpunit/includes/api/ApiWatchTest.php
===================================================================
--- trunk/phase3/maintenance/tests/phpunit/includes/api/ApiWatchTest.php        
2010-09-28 17:20:32 UTC (rev 73920)
+++ trunk/phase3/maintenance/tests/phpunit/includes/api/ApiWatchTest.php        
2010-09-28 18:13:42 UTC (rev 73921)
@@ -5,21 +5,9 @@
 class ApiWatchTest extends ApiTestSetup {
 
        function setUp() {
-               ini_set( 'log_errors', 1 );
-               ini_set( 'error_reporting', 1 );
-               ini_set( 'display_errors', 1 );
-
-               global $wgMemc;
-               $wgMemc = new FakeMemCachedClient;
+               parent::setUp();
        }
 
-       function tearDown() {
-               global $wgMemc;
-
-               $wgMemc = null;
-       }
-
-
        function doApiRequest( $params, $data = null ) {
                $_SESSION = isset( $data[2] ) ? $data[2] : array();
 
@@ -38,7 +26,7 @@
                $data = $this->doApiRequest( array(
                        'action' => 'login',
                        'lgname' => self::$userName,
-                       'lgpassword' => self::$passWord ), $data );
+                       'lgpassword' => self::$passWord ) );
 
                $this->assertArrayHasKey( "login", $data[0] );
                $this->assertArrayHasKey( "result", $data[0]['login'] );
@@ -65,11 +53,12 @@
                        'action' => 'query',
                        'titles' => 'Main Page',
                        'intoken' => 'edit|delete|protect|move|block|unblock',
-                       'prop' => 'info' ), $data );
+                       'prop' => 'info' ) );
 
                $this->assertArrayHasKey( 'query', $data[0] );
                $this->assertArrayHasKey( 'pages', $data[0]['query'] );
-               $key = array_pop( array_keys( $data[0]['query']['pages'] ) );
+               $keys = array_keys( $data[0]['query']['pages'] );
+               $key = array_pop( $keys );
 
                $this->assertArrayHasKey( $key, $data[0]['query']['pages'] );
                $this->assertArrayHasKey( 'edittoken', 
$data[0]['query']['pages'][$key] );
@@ -86,7 +75,8 @@
         * @depends testGetToken
         */
        function testWatchEdit( $data ) {
-               $key = array_pop( array_keys( $data[0]['query']['pages'] ) );
+               $keys = array_keys( $data[0]['query']['pages'] );
+               $key = array_pop( $keys );
                $pageinfo = $data[0]['query']['pages'][$key];
 
                $data = $this->doApiRequest( array(
@@ -135,7 +125,8 @@
         * @depends testGetToken
         */
        function testWatchProtect( $data ) {
-               $key = array_pop( array_keys( $data[0]['query']['pages'] ) );
+               $keys = array_keys( $data[0]['query']['pages'] );
+               $key = array_pop( $keys );
                $pageinfo = $data[0]['query']['pages'][$key];
 
                $data = $this->doApiRequest( array(
@@ -163,7 +154,8 @@
 
                $this->assertArrayHasKey( 'query', $data[0] );
                $this->assertArrayHasKey( 'pages', $data[0]['query'] );
-               $key = array_pop( array_keys( $data[0]['query']['pages'] ) );
+               $keys = array_keys( $data[0]['query']['pages'] );
+               $key = array_pop( $keys );
 
                $this->assertArrayHasKey( 'pageid', 
$data[0]['query']['pages'][$key] );
                $this->assertArrayHasKey( 'revisions', 
$data[0]['query']['pages'][$key] );
@@ -177,7 +169,8 @@
         * @depends testGetRollbackToken
         */
        function testWatchRollback( $data ) {
-               $key = array_pop( array_keys( $data[0]['query']['pages'] ) );
+               $keys = array_keys( $data[0]['query']['pages'] );
+               $key = array_pop( $keys );
                $pageinfo = $data[0]['query']['pages'][$key]['revisions'][0];
 
                $data = $this->doApiRequest( array(
@@ -195,7 +188,8 @@
         * @depends testGetToken
         */
        function testWatchDelete( $data ) {
-               $key = array_pop( array_keys( $data[0]['query']['pages'] ) );
+               $keys = array_keys( $data[0]['query']['pages'] );
+               $key = array_pop( $keys );
                $pageinfo = $data[0]['query']['pages'][$key];
 
                $data = $this->doApiRequest( array(



_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to