<?php
+
use MediaWiki\MediaWikiServices;
use Wikimedia\TestingAccessWrapper;
$handler = ContentHandler::getForTitle( $title );
$lang = $handler->getPageLanguage( $title );
+ $this->assertInstanceOf( Language::class, $lang );
$this->assertEquals( $expected->getCode(), $lang->getCode() );
}
$content = null;
$text = ContentHandler::getContentText( $content );
- $this->assertEquals( '', $text );
+ $this->assertSame( '', $text );
}
public static function dataGetContentText_TextContent() {
$content = new WikitextContent( "hello world" );
$text = ContentHandler::getContentText( $content );
- $this->assertEquals( $content->getNativeData(), $text );
+ $this->assertEquals( $content->getText(), $text );
}
/**
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',
null,
CONTENT_FORMAT_WIKITEXT,
CONTENT_MODEL_WIKITEXT,
- 'hallo',
false
],
[
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
],
[
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 ],
];
}
* @covers ContentHandler::makeContent
*/
public function testMakeContent( $data, $title, $modelId, $format,
- $expectedModelId, $expectedNativeData, $shouldFail
+ $expectedModelId, $shouldFail
) {
$title = Title::newFromText( $title );
MediaWikiServices::getInstance()->getLinkCache()->addBadLinkObj( $title );
}
$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() );
$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(
$customContentHandler2->expects( $this->any() )
->method( 'getSlotDiffRendererInternal' )
->willReturn( $customSlotDiffRenderer );
- /** @var $customContentHandler2 ContentHandler */
+ /** @var ContentHandler $customContentHandler2 */
$slotDiffRenderer = $customContentHandler2->getSlotDiffRenderer( RequestContext::getMain() );
$this->assertSame( $customSlotDiffRenderer, $slotDiffRenderer );
}
$customContentHandler->expects( $this->any() )
->method( 'createDifferenceEngine' )
->willReturn( $customDifferenceEngine );
- /** @var $customContentHandler ContentHandler */
+ /** @var ContentHandler $customContentHandler */
$customSlotDiffRenderer = $this->getMockBuilder( SlotDiffRenderer::class )
->disableOriginalConstructor()
$customContentHandler2->expects( $this->any() )
->method( 'getSlotDiffRendererInternal' )
->willReturn( $customSlotDiffRenderer );
- /** @var $customContentHandler2 ContentHandler */
+ /** @var ContentHandler $customContentHandler2 */
$customSlotDiffRenderer2 = $this->getMockBuilder( SlotDiffRenderer::class )
->disableOriginalConstructor()