Merge "FauxRequest: don’t override getValues()"
[lhc/web/wiklou.git] / tests / phpunit / includes / content / ContentHandlerTest.php
index 43edf60..39b5380 100644 (file)
@@ -1,4 +1,5 @@
 <?php
+
 use MediaWiki\MediaWikiServices;
 use Wikimedia\TestingAccessWrapper;
 
@@ -158,6 +159,7 @@ class ContentHandlerTest extends MediaWikiTestCase {
                $handler = ContentHandler::getForTitle( $title );
                $lang = $handler->getPageLanguage( $title );
 
+               $this->assertInstanceOf( Language::class, $lang );
                $this->assertEquals( $expected->getCode(), $lang->getCode() );
        }
 
@@ -179,7 +181,7 @@ class ContentHandlerTest extends MediaWikiTestCase {
                $content = null;
 
                $text = ContentHandler::getContentText( $content );
-               $this->assertEquals( '', $text );
+               $this->assertSame( '', $text );
        }
 
        public static function dataGetContentText_TextContent() {
@@ -200,7 +202,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 +244,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 +254,6 @@ class ContentHandlerTest extends MediaWikiTestCase {
                                null,
                                CONTENT_FORMAT_WIKITEXT,
                                CONTENT_MODEL_WIKITEXT,
-                               'hallo',
                                false
                        ],
                        [
@@ -261,19 +262,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 +281,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 +295,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 +307,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() );
@@ -522,7 +520,7 @@ class ContentHandlerTest extends MediaWikiTestCase {
                $customContentHandler->expects( $this->any() )
                        ->method( 'createDifferenceEngine' )
                        ->willReturn( $customDifferenceEngine );
-               /** @var $customContentHandler ContentHandler */
+               /** @var ContentHandler $customContentHandler */
                $slotDiffRenderer = $customContentHandler->getSlotDiffRenderer( RequestContext::getMain() );
                $this->assertInstanceOf( DifferenceEngineSlotDiffRenderer::class, $slotDiffRenderer );
                $this->assertSame(
@@ -556,7 +554,7 @@ class ContentHandlerTest extends MediaWikiTestCase {
                $customContentHandler2->expects( $this->any() )
                        ->method( 'getSlotDiffRendererInternal' )
                        ->willReturn( $customSlotDiffRenderer );
-               /** @var $customContentHandler2 ContentHandler */
+               /** @var ContentHandler $customContentHandler2 */
                $slotDiffRenderer = $customContentHandler2->getSlotDiffRenderer( RequestContext::getMain() );
                $this->assertSame( $customSlotDiffRenderer, $slotDiffRenderer );
        }
@@ -580,7 +578,7 @@ class ContentHandlerTest extends MediaWikiTestCase {
                $customContentHandler->expects( $this->any() )
                        ->method( 'createDifferenceEngine' )
                        ->willReturn( $customDifferenceEngine );
-               /** @var $customContentHandler ContentHandler */
+               /** @var ContentHandler $customContentHandler */
 
                $customSlotDiffRenderer = $this->getMockBuilder( SlotDiffRenderer::class )
                        ->disableOriginalConstructor()
@@ -595,7 +593,7 @@ class ContentHandlerTest extends MediaWikiTestCase {
                $customContentHandler2->expects( $this->any() )
                        ->method( 'getSlotDiffRendererInternal' )
                        ->willReturn( $customSlotDiffRenderer );
-               /** @var $customContentHandler2 ContentHandler */
+               /** @var ContentHandler $customContentHandler2 */
 
                $customSlotDiffRenderer2 = $this->getMockBuilder( SlotDiffRenderer::class )
                        ->disableOriginalConstructor()