Convert all array() syntax to []
[lhc/web/wiklou.git] / tests / phpunit / includes / resourceloader / ResourceLoaderTest.php
index 9ef2588..2dfed62 100644 (file)
@@ -5,22 +5,22 @@ class ResourceLoaderTest extends ResourceLoaderTestCase {
        protected function setUp() {
                parent::setUp();
 
-               $this->setMwGlobals( array(
-                       'wgResourceLoaderLESSImportPaths' => array(
+               $this->setMwGlobals( [
+                       'wgResourceLoaderLESSImportPaths' => [
                                dirname( dirname( __DIR__ ) ) . '/data/less/common',
-                       ),
-                       'wgResourceLoaderLESSVars' => array(
+                       ],
+                       'wgResourceLoaderLESSVars' => [
                                'foo'  => '2px',
                                'Foo' => '#eeeeee',
                                'bar' => 5,
-                       ),
-               ) );
+                       ],
+               ] );
        }
 
        public static function provideValidModules() {
-               return array(
-                       array( 'TEST.validModule1', new ResourceLoaderTestModule() ),
-               );
+               return [
+                       [ 'TEST.validModule1', new ResourceLoaderTestModule() ],
+               ];
        }
 
        /**
@@ -31,13 +31,13 @@ class ResourceLoaderTest extends ResourceLoaderTestCase {
        public function testCreatingNewResourceLoaderCallsRegistrationHook() {
                $resourceLoaderRegisterModulesHook = false;
 
-               $this->setMwGlobals( 'wgHooks', array(
-                       'ResourceLoaderRegisterModules' => array(
+               $this->setMwGlobals( 'wgHooks', [
+                       'ResourceLoaderRegisterModules' => [
                                function ( &$resourceLoader ) use ( &$resourceLoaderRegisterModulesHook ) {
                                        $resourceLoaderRegisterModulesHook = true;
                                }
-                       )
-               ) );
+                       ]
+               ] );
 
                $resourceLoader = new ResourceLoader();
                $this->assertTrue(
@@ -67,10 +67,10 @@ class ResourceLoaderTest extends ResourceLoaderTestCase {
        public function testLessFileCompilation() {
                $context = $this->getResourceLoaderContext();
                $basePath = __DIR__ . '/../../data/less/module';
-               $module = new ResourceLoaderFileModule( array(
+               $module = new ResourceLoaderFileModule( [
                        'localBasePath' => $basePath,
-                       'styles' => array( 'styles.less' ),
-               ) );
+                       'styles' => [ 'styles.less' ],
+               ] );
                $module->setName( 'test.less' );
                $styles = $module->getStyles( $context );
                $this->assertStringEqualsFile( $basePath . '/styles.css', $styles['all'] );
@@ -102,45 +102,45 @@ class ResourceLoaderTest extends ResourceLoaderTestCase {
        }
 
        public static function providePackedModules() {
-               return array(
-                       array(
+               return [
+                       [
                                'Example from makePackedModulesString doc comment',
-                               array( 'foo.bar', 'foo.baz', 'bar.baz', 'bar.quux' ),
+                               [ 'foo.bar', 'foo.baz', 'bar.baz', 'bar.quux' ],
                                'foo.bar,baz|bar.baz,quux',
-                       ),
-                       array(
+                       ],
+                       [
                                'Example from expandModuleNames doc comment',
-                               array( 'jquery.foo', 'jquery.bar', 'jquery.ui.baz', 'jquery.ui.quux' ),
+                               [ 'jquery.foo', 'jquery.bar', 'jquery.ui.baz', 'jquery.ui.quux' ],
                                'jquery.foo,bar|jquery.ui.baz,quux',
-                       ),
-                       array(
+                       ],
+                       [
                                'Regression fixed in r88706 with dotless names',
-                               array( 'foo', 'bar', 'baz' ),
+                               [ 'foo', 'bar', 'baz' ],
                                'foo,bar,baz',
-                       ),
-                       array(
+                       ],
+                       [
                                'Prefixless modules after a prefixed module',
-                               array( 'single.module', 'foobar', 'foobaz' ),
+                               [ 'single.module', 'foobar', 'foobaz' ],
                                'single.module|foobar,foobaz',
-                       ),
-               );
+                       ],
+               ];
        }
 
        public static function provideAddSource() {
-               return array(
-                       array( 'examplewiki', '//example.org/w/load.php', 'examplewiki' ),
-                       array( 'example2wiki', array( 'loadScript' => '//example.com/w/load.php' ), 'example2wiki' ),
-                       array(
-                               array( 'foowiki' => '//foo.org/w/load.php', 'bazwiki' => '//baz.org/w/load.php' ),
+               return [
+                       [ 'examplewiki', '//example.org/w/load.php', 'examplewiki' ],
+                       [ 'example2wiki', [ 'loadScript' => '//example.com/w/load.php' ], 'example2wiki' ],
+                       [
+                               [ 'foowiki' => '//foo.org/w/load.php', 'bazwiki' => '//baz.org/w/load.php' ],
                                null,
-                               array( 'foowiki', 'bazwiki' )
-                       ),
-                       array(
-                               array( 'foowiki' => '//foo.org/w/load.php' ),
+                               [ 'foowiki', 'bazwiki' ]
+                       ],
+                       [
+                               [ 'foowiki' => '//foo.org/w/load.php' ],
                                null,
                                false,
-                       ),
-               );
+                       ],
+               ];
        }
 
        /**
@@ -165,28 +165,28 @@ class ResourceLoaderTest extends ResourceLoaderTestCase {
        }
 
        public static function fakeSources() {
-               return array(
-                       'examplewiki' => array(
+               return [
+                       'examplewiki' => [
                                'loadScript' => '//example.org/w/load.php',
                                'apiScript' => '//example.org/w/api.php',
-                       ),
-                       'example2wiki' => array(
+                       ],
+                       'example2wiki' => [
                                'loadScript' => '//example.com/w/load.php',
                                'apiScript' => '//example.com/w/api.php',
-                       ),
-               );
+                       ],
+               ];
        }
 
        public static function provideLoaderImplement() {
-               return array(
-                       array( array(
+               return [
+                       [ [
                                'title' => 'Implement scripts, styles and messages',
 
                                'name' => 'test.example',
                                'scripts' => 'mw.example();',
-                               'styles' => array( 'css' => array( '.mw-example {}' ) ),
-                               'messages' => array( 'example' => '' ),
-                               'templates' => array(),
+                               'styles' => [ 'css' => [ '.mw-example {}' ] ],
+                               'messages' => [ 'example' => '' ],
+                               'templates' => [],
 
                                'expected' => 'mw.loader.implement( "test.example", function ( $, jQuery ) {
 mw.example();
@@ -197,66 +197,66 @@ mw.example();
 }, {
     "example": ""
 } );',
-                       ) ),
-                       array( array(
+                       ] ],
+                       [ [
                                'title' => 'Implement scripts',
 
                                'name' => 'test.example',
                                'scripts' => 'mw.example();',
-                               'styles' => array(),
+                               'styles' => [],
                                'messages' => new XmlJsCode( '{}' ),
-                               'templates' => array(),
+                               'templates' => [],
 
                                'expected' => 'mw.loader.implement( "test.example", function ( $, jQuery ) {
 mw.example();
 } );',
-                       ) ),
-                       array( array(
+                       ] ],
+                       [ [
                                'title' => 'Implement styles',
 
                                'name' => 'test.example',
-                               'scripts' => array(),
-                               'styles' => array( 'css' => array( '.mw-example {}' ) ),
+                               'scripts' => [],
+                               'styles' => [ 'css' => [ '.mw-example {}' ] ],
                                'messages' => new XmlJsCode( '{}' ),
-                               'templates' => array(),
+                               'templates' => [],
 
                                'expected' => 'mw.loader.implement( "test.example", [], {
     "css": [
         ".mw-example {}"
     ]
 } );',
-                       ) ),
-                       array( array(
+                       ] ],
+                       [ [
                                'title' => 'Implement scripts and messages',
 
                                'name' => 'test.example',
                                'scripts' => 'mw.example();',
-                               'styles' => array(),
-                               'messages' => array( 'example' => '' ),
-                               'templates' => array(),
+                               'styles' => [],
+                               'messages' => [ 'example' => '' ],
+                               'templates' => [],
 
                                'expected' => 'mw.loader.implement( "test.example", function ( $, jQuery ) {
 mw.example();
 }, {}, {
     "example": ""
 } );',
-                       ) ),
-                       array( array(
+                       ] ],
+                       [ [
                                'title' => 'Implement scripts and templates',
 
                                'name' => 'test.example',
                                'scripts' => 'mw.example();',
-                               'styles' => array(),
+                               'styles' => [],
                                'messages' => new XmlJsCode( '{}' ),
-                               'templates' => array( 'example.html' => '' ),
+                               'templates' => [ 'example.html' => '' ],
 
                                'expected' => 'mw.loader.implement( "test.example", function ( $, jQuery ) {
 mw.example();
 }, {}, {}, {
     "example.html": ""
 } );',
-                       ) ),
-               );
+                       ] ],
+               ];
        }
 
        /**
@@ -280,11 +280,11 @@ mw.example();
         * @covers ResourceLoader::getLoadScript
         */
        public function testGetLoadScript() {
-               $this->setMwGlobals( 'wgResourceLoaderSources', array() );
+               $this->setMwGlobals( 'wgResourceLoaderSources', [] );
                $rl = new ResourceLoader();
                $sources = self::fakeSources();
                $rl->addSource( $sources );
-               foreach ( array( 'examplewiki', 'example2wiki' ) as $name ) {
+               foreach ( [ 'examplewiki', 'example2wiki' ] as $name ) {
                        $this->assertEquals( $rl->getLoadScript( $name ), $sources[$name]['loadScript'] );
                }