Merge "Stop doing $that = $this in includes/specials"
[lhc/web/wiklou.git] / tests / phpunit / includes / RevisionTest.php
index 48a4017..d2eb6b8 100644 (file)
@@ -9,36 +9,36 @@ class RevisionTest extends MediaWikiTestCase {
 
                parent::setUp();
 
-               $this->setMwGlobals( array(
+               $this->setMwGlobals( [
                        'wgContLang' => Language::factory( 'en' ),
                        'wgLanguageCode' => 'en',
                        'wgLegacyEncoding' => false,
                        'wgCompressRevisions' => false,
 
                        'wgContentHandlerTextFallback' => 'ignore',
-               ) );
+               ] );
 
                $this->mergeMwGlobalArrayValue(
                        'wgExtraNamespaces',
-                       array(
+                       [
                                12312 => 'Dummy',
                                12313 => 'Dummy_talk',
-                       )
+                       ]
                );
 
                $this->mergeMwGlobalArrayValue(
                        'wgNamespaceContentModels',
-                       array(
+                       [
                                12312 => 'testing',
-                       )
+                       ]
                );
 
                $this->mergeMwGlobalArrayValue(
                        'wgContentHandlers',
-                       array(
+                       [
                                'testing' => 'DummyContentHandlerForTesting',
                                'RevisionTestModifyableContent' => 'RevisionTestModifyableContentHandler',
-                       )
+                       ]
                );
 
                MWNamespace::getCanonicalNamespaces( true ); # reset namespace cache
@@ -173,7 +173,7 @@ class RevisionTest extends MediaWikiTestCase {
                        Revision::getRevisionText( $row ), "getRevisionText" );
        }
 
-       # =================================================================================================================
+       # =========================================================================
 
        /**
         * @param string $text
@@ -183,7 +183,9 @@ class RevisionTest extends MediaWikiTestCase {
         *
         * @return Revision
         */
-       function newTestRevision( $text, $title = "Test", $model = CONTENT_MODEL_WIKITEXT, $format = null ) {
+       function newTestRevision( $text, $title = "Test",
+               $model = CONTENT_MODEL_WIKITEXT, $format = null
+       ) {
                if ( is_string( $title ) ) {
                        $title = Title::newFromText( $title );
                }
@@ -191,7 +193,7 @@ class RevisionTest extends MediaWikiTestCase {
                $content = ContentHandler::makeContent( $text, $title, $model, $format );
 
                $rev = new Revision(
-                       array(
+                       [
                                'id' => 42,
                                'page' => 23,
                                'title' => $title,
@@ -202,19 +204,19 @@ class RevisionTest extends MediaWikiTestCase {
                                'minor_edit' => false,
 
                                'content_format' => $format,
-                       )
+                       ]
                );
 
                return $rev;
        }
 
        function dataGetContentModel() {
-               //NOTE: we expect the help namespace to always contain wikitext
-               return array(
-                       array( 'hello world', 'Help:Hello', null, null, CONTENT_MODEL_WIKITEXT ),
-                       array( 'hello world', 'User:hello/there.css', null, null, CONTENT_MODEL_CSS ),
-                       array( serialize( 'hello world' ), 'Dummy:Hello', null, null, "testing" ),
-               );
+               // NOTE: we expect the help namespace to always contain wikitext
+               return [
+                       [ 'hello world', 'Help:Hello', null, null, CONTENT_MODEL_WIKITEXT ],
+                       [ 'hello world', 'User:hello/there.css', null, null, CONTENT_MODEL_CSS ],
+                       [ serialize( 'hello world' ), 'Dummy:Hello', null, null, "testing" ],
+               ];
        }
 
        /**
@@ -229,13 +231,13 @@ class RevisionTest extends MediaWikiTestCase {
        }
 
        function dataGetContentFormat() {
-               //NOTE: we expect the help namespace to always contain wikitext
-               return array(
-                       array( 'hello world', 'Help:Hello', null, null, CONTENT_FORMAT_WIKITEXT ),
-                       array( 'hello world', 'Help:Hello', CONTENT_MODEL_CSS, null, CONTENT_FORMAT_CSS ),
-                       array( 'hello world', 'User:hello/there.css', null, null, CONTENT_FORMAT_CSS ),
-                       array( serialize( 'hello world' ), 'Dummy:Hello', null, null, "testing" ),
-               );
+               // NOTE: we expect the help namespace to always contain wikitext
+               return [
+                       [ 'hello world', 'Help:Hello', null, null, CONTENT_FORMAT_WIKITEXT ],
+                       [ 'hello world', 'Help:Hello', CONTENT_MODEL_CSS, null, CONTENT_FORMAT_CSS ],
+                       [ 'hello world', 'User:hello/there.css', null, null, CONTENT_FORMAT_CSS ],
+                       [ serialize( 'hello world' ), 'Dummy:Hello', null, null, "testing" ],
+               ];
        }
 
        /**
@@ -250,12 +252,12 @@ class RevisionTest extends MediaWikiTestCase {
        }
 
        function dataGetContentHandler() {
-               //NOTE: we expect the help namespace to always contain wikitext
-               return array(
-                       array( 'hello world', 'Help:Hello', null, null, 'WikitextContentHandler' ),
-                       array( 'hello world', 'User:hello/there.css', null, null, 'CssContentHandler' ),
-                       array( serialize( 'hello world' ), 'Dummy:Hello', null, null, 'DummyContentHandlerForTesting' ),
-               );
+               // NOTE: we expect the help namespace to always contain wikitext
+               return [
+                       [ 'hello world', 'Help:Hello', null, null, 'WikitextContentHandler' ],
+                       [ 'hello world', 'User:hello/there.css', null, null, 'CssContentHandler' ],
+                       [ serialize( 'hello world' ), 'Dummy:Hello', null, null, 'DummyContentHandlerForTesting' ],
+               ];
        }
 
        /**
@@ -270,12 +272,26 @@ class RevisionTest extends MediaWikiTestCase {
        }
 
        function dataGetContent() {
-               //NOTE: we expect the help namespace to always contain wikitext
-               return array(
-                       array( 'hello world', 'Help:Hello', null, null, Revision::FOR_PUBLIC, 'hello world' ),
-                       array( serialize( 'hello world' ), 'Hello', "testing", null, Revision::FOR_PUBLIC, serialize( 'hello world' ) ),
-                       array( serialize( 'hello world' ), 'Dummy:Hello', null, null, Revision::FOR_PUBLIC, serialize( 'hello world' ) ),
-               );
+               // NOTE: we expect the help namespace to always contain wikitext
+               return [
+                       [ 'hello world', 'Help:Hello', null, null, Revision::FOR_PUBLIC, 'hello world' ],
+                       [
+                               serialize( 'hello world' ),
+                               'Hello',
+                               "testing",
+                               null,
+                               Revision::FOR_PUBLIC,
+                               serialize( 'hello world' )
+                       ],
+                       [
+                               serialize( 'hello world' ),
+                               'Dummy:Hello',
+                               null,
+                               null,
+                               Revision::FOR_PUBLIC,
+                               serialize( 'hello world' )
+                       ],
+               ];
        }
 
        /**
@@ -283,20 +299,25 @@ class RevisionTest extends MediaWikiTestCase {
         * @dataProvider dataGetContent
         * @covers Revision::getContent
         */
-       public function testGetContent( $text, $title, $model, $format, $audience, $expectedSerialization ) {
+       public function testGetContent( $text, $title, $model, $format,
+               $audience, $expectedSerialization
+       ) {
                $rev = $this->newTestRevision( $text, $title, $model, $format );
                $content = $rev->getContent( $audience );
 
-               $this->assertEquals( $expectedSerialization, is_null( $content ) ? null : $content->serialize( $format ) );
+               $this->assertEquals(
+                       $expectedSerialization,
+                       is_null( $content ) ? null : $content->serialize( $format )
+               );
        }
 
        function dataGetText() {
-               //NOTE: we expect the help namespace to always contain wikitext
-               return array(
-                       array( 'hello world', 'Help:Hello', null, null, Revision::FOR_PUBLIC, 'hello world' ),
-                       array( serialize( 'hello world' ), 'Hello', "testing", null, Revision::FOR_PUBLIC, null ),
-                       array( serialize( 'hello world' ), 'Dummy:Hello', null, null, Revision::FOR_PUBLIC, null ),
-               );
+               // NOTE: we expect the help namespace to always contain wikitext
+               return [
+                       [ 'hello world', 'Help:Hello', null, null, Revision::FOR_PUBLIC, 'hello world' ],
+                       [ serialize( 'hello world' ), 'Hello', "testing", null, Revision::FOR_PUBLIC, null ],
+                       [ serialize( 'hello world' ), 'Dummy:Hello', null, null, Revision::FOR_PUBLIC, null ],
+               ];
        }
 
        /**
@@ -326,10 +347,10 @@ class RevisionTest extends MediaWikiTestCase {
        }
 
        public function dataGetSize() {
-               return array(
-                       array( "hello world.", CONTENT_MODEL_WIKITEXT, 12 ),
-                       array( serialize( "hello world." ), "testing", 12 ),
-               );
+               return [
+                       [ "hello world.", CONTENT_MODEL_WIKITEXT, 12 ],
+                       [ serialize( "hello world." ), "testing", 12 ],
+               ];
        }
 
        /**
@@ -343,10 +364,14 @@ class RevisionTest extends MediaWikiTestCase {
        }
 
        public function dataGetSha1() {
-               return array(
-                       array( "hello world.", CONTENT_MODEL_WIKITEXT, Revision::base36Sha1( "hello world." ) ),
-                       array( serialize( "hello world." ), "testing", Revision::base36Sha1( serialize( "hello world." ) ) ),
-               );
+               return [
+                       [ "hello world.", CONTENT_MODEL_WIKITEXT, Revision::base36Sha1( "hello world." ) ],
+                       [
+                               serialize( "hello world." ),
+                               "testing",
+                               Revision::base36Sha1( serialize( "hello world." ) )
+                       ],
+               ];
        }
 
        /**
@@ -365,10 +390,10 @@ class RevisionTest extends MediaWikiTestCase {
        public function testConstructWithText() {
                $this->hideDeprecated( "Revision::getText" );
 
-               $rev = new Revision( array(
+               $rev = new Revision( [
                        'text' => 'hello world.',
                        'content_model' => CONTENT_MODEL_JAVASCRIPT
-               ) );
+               ] );
 
                $this->assertNotNull( $rev->getText(), 'no content text' );
                $this->assertNotNull( $rev->getContent(), 'no content object available' );
@@ -384,9 +409,9 @@ class RevisionTest extends MediaWikiTestCase {
 
                $title = Title::newFromText( 'RevisionTest_testConstructWithContent' );
 
-               $rev = new Revision( array(
+               $rev = new Revision( [
                        'content' => ContentHandler::makeContent( 'hello world.', $title, CONTENT_MODEL_JAVASCRIPT ),
-               ) );
+               ] );
 
                $this->assertNotNull( $rev->getText(), 'no content text' );
                $this->assertNotNull( $rev->getContent(), 'no content object available' );
@@ -404,7 +429,7 @@ class RevisionTest extends MediaWikiTestCase {
                $content = new RevisionTestModifyableContent( "foo" );
 
                $rev = new Revision(
-                       array(
+                       [
                                'id' => 42,
                                'page' => 23,
                                'title' => Title::newFromText( "testGetContentClone_dummy" ),
@@ -413,15 +438,17 @@ class RevisionTest extends MediaWikiTestCase {
                                'length' => $content->getSize(),
                                'comment' => "testing",
                                'minor_edit' => false,
-                       )
+                       ]
                );
 
                $content = $rev->getContent( Revision::RAW );
                $content->setText( "bar" );
 
                $content2 = $rev->getContent( Revision::RAW );
-               $this->assertNotSame( $content, $content2, "expected a clone" ); // content is mutable, expect clone
-               $this->assertEquals( "foo", $content2->getText() ); // clone should contain the original text
+               // content is mutable, expect clone
+               $this->assertNotSame( $content, $content2, "expected a clone" );
+               // clone should contain the original text
+               $this->assertEquals( "foo", $content2->getText() );
 
                $content2->setText( "bla bla" );
                $this->assertEquals( "bar", $content->getText() ); // clones should be independent
@@ -464,7 +491,7 @@ class RevisionTestModifyableContent extends TextContent {
 class RevisionTestModifyableContentHandler extends TextContentHandler {
 
        public function __construct() {
-               parent::__construct( "RevisionTestModifyableContent", array( CONTENT_FORMAT_TEXT ) );
+               parent::__construct( "RevisionTestModifyableContent", [ CONTENT_FORMAT_TEXT ] );
        }
 
        public function unserializeContent( $text, $format = null ) {