Merge "upload: Simplify file extension extraction in UploadBase"
[lhc/web/wiklou.git] / tests / phpunit / includes / content / ContentHandlerTest.php
index 43edf60..f42f8b4 100644 (file)
@@ -158,6 +158,7 @@ class ContentHandlerTest extends MediaWikiTestCase {
                $handler = ContentHandler::getForTitle( $title );
                $lang = $handler->getPageLanguage( $title );
 
+               $this->assertInstanceOf( Language::class, $lang );
                $this->assertEquals( $expected->getCode(), $lang->getCode() );
        }
 
@@ -200,7 +201,7 @@ class ContentHandlerTest extends MediaWikiTestCase {
                $content = new WikitextContent( "hello world" );
 
                $text = ContentHandler::getContentText( $content );
-               $this->assertEquals( $content->getNativeData(), $text );
+               $this->assertEquals( $content->getText(), $text );
        }
 
        /**
@@ -242,9 +243,9 @@ class ContentHandlerTest extends MediaWikiTestCase {
 
        public static function dataMakeContent() {
                return [
-                       [ 'hallo', 'Help:Test', null, null, CONTENT_MODEL_WIKITEXT, 'hallo', false ],
-                       [ 'hallo', 'MediaWiki:Test.js', null, null, CONTENT_MODEL_JAVASCRIPT, 'hallo', false ],
-                       [ serialize( 'hallo' ), 'Dummy:Test', null, null, "testing", 'hallo', false ],
+                       [ 'hallo', 'Help:Test', null, null, CONTENT_MODEL_WIKITEXT, false ],
+                       [ 'hallo', 'MediaWiki:Test.js', null, null, CONTENT_MODEL_JAVASCRIPT, false ],
+                       [ serialize( 'hallo' ), 'Dummy:Test', null, null, "testing", false ],
 
                        [
                                'hallo',
@@ -252,7 +253,6 @@ class ContentHandlerTest extends MediaWikiTestCase {
                                null,
                                CONTENT_FORMAT_WIKITEXT,
                                CONTENT_MODEL_WIKITEXT,
-                               'hallo',
                                false
                        ],
                        [
@@ -261,19 +261,17 @@ class ContentHandlerTest extends MediaWikiTestCase {
                                null,
                                CONTENT_FORMAT_JAVASCRIPT,
                                CONTENT_MODEL_JAVASCRIPT,
-                               'hallo',
                                false
                        ],
-                       [ serialize( 'hallo' ), 'Dummy:Test', null, "testing", "testing", 'hallo', false ],
+                       [ serialize( 'hallo' ), 'Dummy:Test', null, "testing", "testing", false ],
 
-                       [ 'hallo', 'Help:Test', CONTENT_MODEL_CSS, null, CONTENT_MODEL_CSS, 'hallo', false ],
+                       [ 'hallo', 'Help:Test', CONTENT_MODEL_CSS, null, CONTENT_MODEL_CSS, false ],
                        [
                                'hallo',
                                'MediaWiki:Test.js',
                                CONTENT_MODEL_CSS,
                                null,
                                CONTENT_MODEL_CSS,
-                               'hallo',
                                false
                        ],
                        [
@@ -282,13 +280,12 @@ class ContentHandlerTest extends MediaWikiTestCase {
                                CONTENT_MODEL_CSS,
                                null,
                                CONTENT_MODEL_CSS,
-                               serialize( 'hallo' ),
                                false
                        ],
 
-                       [ 'hallo', 'Help:Test', CONTENT_MODEL_WIKITEXT, "testing", null, null, true ],
-                       [ 'hallo', 'MediaWiki:Test.js', CONTENT_MODEL_CSS, "testing", null, null, true ],
-                       [ 'hallo', 'Dummy:Test', CONTENT_MODEL_JAVASCRIPT, "testing", null, null, true ],
+                       [ 'hallo', 'Help:Test', CONTENT_MODEL_WIKITEXT, "testing", null, true ],
+                       [ 'hallo', 'MediaWiki:Test.js', CONTENT_MODEL_CSS, "testing", null, true ],
+                       [ 'hallo', 'Dummy:Test', CONTENT_MODEL_JAVASCRIPT, "testing", null, true ],
                ];
        }
 
@@ -297,7 +294,7 @@ class ContentHandlerTest extends MediaWikiTestCase {
         * @covers ContentHandler::makeContent
         */
        public function testMakeContent( $data, $title, $modelId, $format,
-               $expectedModelId, $expectedNativeData, $shouldFail
+               $expectedModelId, $shouldFail
        ) {
                $title = Title::newFromText( $title );
                MediaWikiServices::getInstance()->getLinkCache()->addBadLinkObj( $title );
@@ -309,7 +306,7 @@ class ContentHandlerTest extends MediaWikiTestCase {
                        }
 
                        $this->assertEquals( $expectedModelId, $content->getModel(), 'bad model id' );
-                       $this->assertEquals( $expectedNativeData, $content->getNativeData(), 'bads native data' );
+                       $this->assertEquals( $data, $content->serialize(), 'bad serialized data' );
                } catch ( MWException $ex ) {
                        if ( !$shouldFail ) {
                                $this->fail( "ContentHandler::makeContent failed unexpectedly: " . $ex->getMessage() );