28 $this->assertEquals(
'hello world', $this->
handler->serializeContent(
$content ) );
36 $this->fail(
"serializeContent() should have failed on unknown format" );
47 $this->assertEquals(
'hello world',
$content->getNativeData() );
50 $this->assertEquals(
'hello world',
$content->getNativeData() );
53 $this->
handler->unserializeContent(
'hello world',
'dummy/foo' );
54 $this->fail(
"unserializeContent() should have failed on unknown format" );
66 $this->assertTrue(
$content->isEmpty() );
67 $this->assertEquals(
'',
$content->getNativeData() );
85 MediaWikiServices::getInstance()->getContentLanguage()->resetNamespaces();
87 MediaWikiServices::getInstance()->resetServiceForTesting(
'MagicWordFactory' );
89 if ( is_string( $title ) ) {
90 $title = Title::newFromText( $title );
93 $this->assertEquals( $expected,
$content->serialize() );
98 [
'Hello',
'#REDIRECT [[Hello]]' ],
99 [
'Template:Hello',
'#REDIRECT [[Template:Hello]]' ],
100 [
'Hello#section',
'#REDIRECT [[Hello#section]]' ],
101 [
'user:john_doe#section',
'#REDIRECT [[User:John doe#section]]' ],
102 [
'MEDIAWIKI:FOOBAR',
'#REDIRECT [[MediaWiki:FOOBAR]]' ],
103 [
'Category:Foo',
'#REDIRECT [[:Category:Foo]]' ],
104 [ Title::makeTitle(
NS_MAIN,
'en:Foo' ),
'#REDIRECT [[en:Foo]]' ],
105 [ Title::makeTitle(
NS_MAIN,
'Foo',
'',
'en' ),
'#REDIRECT [[:en:Foo]]' ],
107 Title::makeTitle(
NS_MAIN,
'Bar',
'fragment',
'google' ),
108 '#REDIRECT [[google:Bar#fragment]]'
118 $this->assertEquals( $supported, $this->
handler->isSupportedFormat( $format ) );
125 $handler =
new WikiTextContentHandler();
165 public function testMerge3( $old, $mine, $yours, $expected ) {
173 $merged = $this->
handler->merge3( $oldContent, $myContent, $yourContent );
175 $this->assertEquals( $expected, $merged ? $merged->getNativeData() : $merged );
181 'Hello there, world!',
184 '/^Redirected page .*Foo/'
191 '/^Created page .*Hello/'
198 '/^Created blank page$/'
202 'Hello there, world!',
209 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
210 eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
211 voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
212 clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.',
215 '/^Replaced .*Hello/'
235 $summary = $this->
handler->getAutosummary( $oldContent, $newContent, $flags );
238 (
bool)preg_match( $expected, $summary ),
239 "Autosummary didn't match expected pattern $expected: $summary"
263 'mw-removed-redirect'
270 'mw-changed-redirect-target'
295 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
296 eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
297 voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
298 clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.',
305 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
306 eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
307 voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
308 clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.',
309 'Duis purus odio, rhoncus et finibus dapibus, facilisis ac urna. Pellentesque
310 arcu, tristique nec tempus nec, suscipit vel arcu. Sed non dolor nec ligula
311 congue tempor. Quisque pellentesque finibus orci a molestie. Nam maximus, purus
312 euismod finibus mollis, dui ante malesuada felis, dignissim rutrum diam sapien.',
325 'mw-new-redirect' =>
true,
326 'mw-removed-redirect' =>
true,
327 'mw-changed-redirect-target' =>
true,
328 'mw-newpage' =>
true,
329 'mw-newblank' =>
true,
331 'mw-replace' =>
true,
336 $tag = $this->
handler->getChangeTag( $oldContent, $newContent, $flags );
338 $this->assertSame( $expected, $tag );
345 $mockEngine = $this->createMock( SearchEngine::class );
346 $title = Title::newFromText(
'Somefile.jpg',
NS_FILE );
349 $fileHandler = $this->getMockBuilder( FileContentHandler::class )
350 ->disableOriginalConstructor()
351 ->setMethods( [
'getDataForSearchIndex' ] )
354 $handler = $this->getMockBuilder( WikitextContentHandler::class )
355 ->disableOriginalConstructor()
356 ->setMethods( [
'getFileHandler' ] )
359 $handler->method(
'getFileHandler' )->will( $this->returnValue( $fileHandler ) );
360 $fileHandler->expects( $this->once() )
361 ->method(
'getDataForSearchIndex' )
362 ->will( $this->returnValue( [
'file_text' =>
'This is file content' ] ) );
365 $this->assertArrayHasKey(
'file_text', $data );
366 $this->assertEquals(
'This is file content', $data[
'file_text'] );
370 $title = Title::newFromText(
'Somefile.jpg',
NS_FILE );
374 $srp = $this->getMock( SlotRenderingProvider::class );
379 $this->assertEquals( [], $updates );
383 $title = Title::newFromText(
'Somefile.jpg',
NS_FILE );
386 $srp = $this->getMock( SlotRenderingProvider::class );
391 $this->assertEquals( [], $updates );
A content handler knows how do deal with a specific type of content on a wiki page.
getSecondaryDataUpdates(Title $title, Content $content, $role, SlotRenderingProvider $slotOutput)
Returns a list of DeferrableUpdate objects for recording information about the given Content in some ...
supportsDirectEditing()
Return true if this content model supports direct editing, such as via EditPage.
getDeletionUpdates(Title $title, $role)
Returns a list of DeferrableUpdate objects for removing information about content in some secondary d...
getDataForSearchIndex(WikiPage $page, ParserOutput $output, SearchEngine $engine)
Return fields to be indexed by search engine as representation of this document.
Class representing a MediaWiki article and history.
testGetSecondaryDataUpdates()
testMerge3( $old, $mine, $yours, $expected)
dataMerge3 WikitextContentHandler::merge3
testMakeRedirectContent( $title, $expected)
provideMakeRedirectContent
testGetChangeTag( $old, $new, $flags, $expected)
dataGetChangeTag WikitextContentHandler::getChangeTag
testSupportsDirectEditing()
WikitextContentHandler::supportsDirectEditing.
static dataGetAutosummary()
testGetAutosummary( $old, $new, $flags, $expected)
dataGetAutosummary WikitextContentHandler::getAutosummary
testMakeEmptyContent()
WikitextContentHandler::makeEmptyContent.
testDataIndexFieldsFile()
WikitextContentHandler::getDataForSearchIndex.
testSerializeContent()
WikitextContentHandler::serializeContent.
static provideMakeRedirectContent()
testIsSupportedFormat( $format, $supported)
dataIsSupportedFormat WikitextContentHandler::isSupportedFormat
static dataGetChangeTag()
testUnserializeContent()
WikitextContentHandler::unserializeContent.
static dataIsSupportedFormat()
Content handler for wiki text pages.
Content object for wiki text pages.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable modifiable after all normalizations have been except for the $wgMaxImageArea check set to true or false to override the $wgMaxImageArea check result gives extension the possibility to transform it themselves set to a MediaTransformOutput the error message to be returned in an array you should do so by altering $wgNamespaceProtection and $wgNamespaceContentModels outside the handler
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
processing should stop and the error should be shown to the user * false
returning false will NOT prevent logging $e
const CONTENT_MODEL_WIKITEXT
const CONTENT_FORMAT_WIKITEXT