Convert all array() syntax to []
[lhc/web/wiklou.git] / tests / phpunit / includes / HooksTest.php
index 87af6c1..527e129 100644 (file)
@@ -12,25 +12,40 @@ class HooksTest extends MediaWikiTestCase {
        public static function provideHooks() {
                $i = new NothingClass();
 
-               return array(
-                       array( 'Object and method', array( $i, 'someNonStatic' ), 'changed-nonstatic', 'changed-nonstatic' ),
-                       array( 'Object and no method', array( $i ), 'changed-onevent', 'original' ),
-                       array( 'Object and method with data', array( $i, 'someNonStaticWithData', 'data' ), 'data', 'original' ),
-                       array( 'Object and static method', array( $i, 'someStatic' ), 'changed-static', 'original' ),
-                       array( 'Class::method static call', array( 'NothingClass::someStatic' ), 'changed-static', 'original' ),
-                       array( 'Global function', array( 'NothingFunction' ), 'changed-func', 'original' ),
-                       array( 'Global function with data', array( 'NothingFunctionData', 'data' ), 'data', 'original' ),
-                       array( 'Closure', array( function ( &$foo, $bar ) {
+               return [
+                       [
+                               'Object and method',
+                               [ $i, 'someNonStatic' ],
+                               'changed-nonstatic',
+                               'changed-nonstatic'
+                       ],
+                       [ 'Object and no method', [ $i ], 'changed-onevent', 'original' ],
+                       [
+                               'Object and method with data',
+                               [ $i, 'someNonStaticWithData', 'data' ],
+                               'data',
+                               'original'
+                       ],
+                       [ 'Object and static method', [ $i, 'someStatic' ], 'changed-static', 'original' ],
+                       [
+                               'Class::method static call',
+                               [ 'NothingClass::someStatic' ],
+                               'changed-static',
+                               'original'
+                       ],
+                       [ 'Global function', [ 'NothingFunction' ], 'changed-func', 'original' ],
+                       [ 'Global function with data', [ 'NothingFunctionData', 'data' ], 'data', 'original' ],
+                       [ 'Closure', [ function ( &$foo, $bar ) {
                                $foo = 'changed-closure';
 
                                return true;
-                       } ), 'changed-closure', 'original' ),
-                       array( 'Closure with data', array( function ( $data, &$foo, $bar ) {
+                       } ], 'changed-closure', 'original' ],
+                       [ 'Closure with data', [ function ( $data, &$foo, $bar ) {
                                $foo = $data;
 
                                return true;
-                       }, 'data' ), 'data', 'original' )
-               );
+                       }, 'data' ], 'data', 'original' ]
+               ];
        }
 
        /**
@@ -42,7 +57,7 @@ class HooksTest extends MediaWikiTestCase {
                $foo = $bar = 'original';
 
                $wgHooks['MediaWikiHooksTest001'][] = $hook;
-               wfRunHooks( 'MediaWikiHooksTest001', array( &$foo, &$bar ) );
+               wfRunHooks( 'MediaWikiHooksTest001', [ &$foo, &$bar ] );
 
                $this->assertSame( $expectedFoo, $foo, $msg );
                $this->assertSame( $expectedBar, $bar, $msg );
@@ -57,7 +72,7 @@ class HooksTest extends MediaWikiTestCase {
                $foo = $bar = 'original';
 
                Hooks::register( 'MediaWikiHooksTest001', $hook );
-               Hooks::run( 'MediaWikiHooksTest001', array( &$foo, &$bar ) );
+               Hooks::run( 'MediaWikiHooksTest001', [ &$foo, &$bar ] );
 
                $this->assertSame( $expectedFoo, $foo, $msg );
                $this->assertSame( $expectedBar, $bar, $msg );
@@ -76,17 +91,32 @@ class HooksTest extends MediaWikiTestCase {
                $b = new NothingClass();
 
                $wgHooks['MediaWikiHooksTest001'][] = $a;
-               $this->assertTrue( Hooks::isRegistered( 'MediaWikiHooksTest001' ), 'Hook registered via $wgHooks should be noticed by Hooks::isRegistered' );
+               $this->assertTrue(
+                       Hooks::isRegistered( 'MediaWikiHooksTest001' ),
+                       'Hook registered via $wgHooks should be noticed by Hooks::isRegistered'
+               );
 
                Hooks::register( 'MediaWikiHooksTest001', $b );
-               $this->assertEquals( 2, count( Hooks::getHandlers( 'MediaWikiHooksTest001' ) ), 'Hooks::getHandlers() should return hooks registered via wgHooks as well as Hooks::register' );
+               $this->assertEquals(
+                       2,
+                       count( Hooks::getHandlers( 'MediaWikiHooksTest001' ) ),
+                       'Hooks::getHandlers() should return hooks registered via wgHooks as well as Hooks::register'
+               );
 
                $foo = 'quux';
                $bar = 'qaax';
 
-               Hooks::run( 'MediaWikiHooksTest001', array( &$foo, &$bar ) );
-               $this->assertEquals( 1, $a->calls, 'Hooks::run() should run hooks registered via wgHooks as well as Hooks::register' );
-               $this->assertEquals( 1, $b->calls, 'Hooks::run() should run hooks registered via wgHooks as well as Hooks::register' );
+               Hooks::run( 'MediaWikiHooksTest001', [ &$foo, &$bar ] );
+               $this->assertEquals(
+                       1,
+                       $a->calls,
+                       'Hooks::run() should run hooks registered via wgHooks as well as Hooks::register'
+               );
+               $this->assertEquals(
+                       1,
+                       $b->calls,
+                       'Hooks::run() should run hooks registered via wgHooks as well as Hooks::register'
+               );
        }
 
        /**
@@ -95,7 +125,7 @@ class HooksTest extends MediaWikiTestCase {
         */
        public function testUncallableFunction() {
                Hooks::register( 'MediaWikiHooksTest001', 'ThisFunctionDoesntExist' );
-               Hooks::run( 'MediaWikiHooksTest001', array() );
+               Hooks::run( 'MediaWikiHooksTest001', [] );
        }
 
        /**
@@ -111,7 +141,7 @@ class HooksTest extends MediaWikiTestCase {
                        return true;
                } );
                $foo = 'original';
-               Hooks::run( 'MediaWikiHooksTest001', array( &$foo ) );
+               Hooks::run( 'MediaWikiHooksTest001', [ &$foo ] );
                $this->assertSame( 'original', $foo, 'Hooks continued processing after a false return.' );
        }
 
@@ -123,7 +153,7 @@ class HooksTest extends MediaWikiTestCase {
                Hooks::register( 'MediaWikiHooksTest001', function () {
                        return 'test';
                } );
-               Hooks::run( 'MediaWikiHooksTest001', array() );
+               Hooks::run( 'MediaWikiHooksTest001', [] );
        }
 }