MediaWiki  1.32.5
ContentHandlerTest.php
Go to the documentation of this file.
1 <?php
3 use Wikimedia\TestingAccessWrapper;
4 
10 
11  protected function setUp() {
12  parent::setUp();
13 
14  $this->setMwGlobals( [
15  'wgExtraNamespaces' => [
16  12312 => 'Dummy',
17  12313 => 'Dummy_talk',
18  ],
19  // The below tests assume that namespaces not mentioned here (Help, User, MediaWiki, ..)
20  // default to CONTENT_MODEL_WIKITEXT.
21  'wgNamespaceContentModels' => [
22  12312 => 'testing',
23  ],
24  'wgContentHandlers' => [
31  'testing-callbacks' => function ( $modelId ) {
32  return new DummyContentHandlerForTesting( $modelId );
33  }
34  ],
35  ] );
36 
37  // Reset LinkCache
38  MediaWikiServices::getInstance()->resetServiceForTesting( 'LinkCache' );
39  }
40 
41  protected function tearDown() {
42  // Reset LinkCache
43  MediaWikiServices::getInstance()->resetServiceForTesting( 'LinkCache' );
44 
45  parent::tearDown();
46  }
47 
48  public function addDBDataOnce() {
49  $this->insertPage( 'Not_Main_Page', 'This is not a main page' );
50  $this->insertPage( 'Smithee', 'A smithee is one who smiths. See also [[Alan Smithee]]' );
51  }
52 
53  public static function dataGetDefaultModelFor() {
54  return [
55  [ 'Help:Foo', CONTENT_MODEL_WIKITEXT ],
56  [ 'Help:Foo.js', CONTENT_MODEL_WIKITEXT ],
57  [ 'Help:Foo.css', CONTENT_MODEL_WIKITEXT ],
58  [ 'Help:Foo.json', CONTENT_MODEL_WIKITEXT ],
59  [ 'Help:Foo/bar.js', CONTENT_MODEL_WIKITEXT ],
60  [ 'User:Foo', CONTENT_MODEL_WIKITEXT ],
61  [ 'User:Foo.js', CONTENT_MODEL_WIKITEXT ],
62  [ 'User:Foo.css', CONTENT_MODEL_WIKITEXT ],
63  [ 'User:Foo.json', CONTENT_MODEL_WIKITEXT ],
64  [ 'User:Foo/bar.js', CONTENT_MODEL_JAVASCRIPT ],
65  [ 'User:Foo/bar.css', CONTENT_MODEL_CSS ],
66  [ 'User:Foo/bar.json', CONTENT_MODEL_JSON ],
67  [ 'User:Foo/bar.json.nope', CONTENT_MODEL_WIKITEXT ],
68  [ 'User talk:Foo/bar.css', CONTENT_MODEL_WIKITEXT ],
69  [ 'User:Foo/bar.js.xxx', CONTENT_MODEL_WIKITEXT ],
70  [ 'User:Foo/bar.xxx', CONTENT_MODEL_WIKITEXT ],
71  [ 'MediaWiki:Foo.js', CONTENT_MODEL_JAVASCRIPT ],
72  [ 'MediaWiki:Foo.JS', CONTENT_MODEL_WIKITEXT ],
73  [ 'MediaWiki:Foo.css', CONTENT_MODEL_CSS ],
74  [ 'MediaWiki:Foo.css.xxx', CONTENT_MODEL_WIKITEXT ],
75  [ 'MediaWiki:Foo.CSS', CONTENT_MODEL_WIKITEXT ],
76  [ 'MediaWiki:Foo.json', CONTENT_MODEL_JSON ],
77  [ 'MediaWiki:Foo.JSON', CONTENT_MODEL_WIKITEXT ],
78  ];
79  }
80 
85  public function testGetDefaultModelFor( $title, $expectedModelId ) {
87  $this->assertEquals( $expectedModelId, ContentHandler::getDefaultModelFor( $title ) );
88  }
89 
94  public function testGetForTitle( $title, $expectedContentModel ) {
96  MediaWikiServices::getInstance()->getLinkCache()->addBadLinkObj( $title );
98  $this->assertEquals( $expectedContentModel, $handler->getModelID() );
99  }
100 
101  public static function dataGetLocalizedName() {
102  return [
103  [ null, null ],
104  [ "xyzzy", null ],
105 
106  // XXX: depends on content language
107  [ CONTENT_MODEL_JAVASCRIPT, '/javascript/i' ],
108  ];
109  }
110 
115  public function testGetLocalizedName( $id, $expected ) {
117 
118  if ( $expected ) {
119  $this->assertNotNull( $name, "no name found for content model $id" );
120  $this->assertTrue( preg_match( $expected, $name ) > 0,
121  "content model name for #$id did not match pattern $expected"
122  );
123  } else {
124  $this->assertEquals( $id, $name, "localization of unknown model $id should have "
125  . "fallen back to use the model id directly."
126  );
127  }
128  }
129 
130  public static function dataGetPageLanguage() {
131  global $wgLanguageCode;
132 
133  return [
134  [ "Main", $wgLanguageCode ],
135  [ "Dummy:Foo", $wgLanguageCode ],
136  [ "MediaWiki:common.js", 'en' ],
137  [ "User:Foo/common.js", 'en' ],
138  [ "MediaWiki:common.css", 'en' ],
139  [ "User:Foo/common.css", 'en' ],
140  [ "User:Foo", $wgLanguageCode ],
141 
142  [ CONTENT_MODEL_JAVASCRIPT, 'javascript' ],
143  ];
144  }
145 
150  public function testGetPageLanguage( $title, $expected ) {
151  if ( is_string( $title ) ) {
153  MediaWikiServices::getInstance()->getLinkCache()->addBadLinkObj( $title );
154  }
155 
156  $expected = wfGetLangObj( $expected );
157 
159  $lang = $handler->getPageLanguage( $title );
160 
161  $this->assertEquals( $expected->getCode(), $lang->getCode() );
162  }
163 
164  public static function dataGetContentText_Null() {
165  return [
166  [ 'fail' ],
167  [ 'serialize' ],
168  [ 'ignore' ],
169  ];
170  }
171 
176  public function testGetContentText_Null( $contentHandlerTextFallback ) {
177  $this->setMwGlobals( 'wgContentHandlerTextFallback', $contentHandlerTextFallback );
178 
179  $content = null;
180 
182  $this->assertEquals( '', $text );
183  }
184 
185  public static function dataGetContentText_TextContent() {
186  return [
187  [ 'fail' ],
188  [ 'serialize' ],
189  [ 'ignore' ],
190  ];
191  }
192 
197  public function testGetContentText_TextContent( $contentHandlerTextFallback ) {
198  $this->setMwGlobals( 'wgContentHandlerTextFallback', $contentHandlerTextFallback );
199 
200  $content = new WikitextContent( "hello world" );
201 
203  $this->assertEquals( $content->getNativeData(), $text );
204  }
205 
212  $this->setMwGlobals( 'wgContentHandlerTextFallback', 'fail' );
213 
214  $content = new DummyContentForTesting( "hello world" );
215 
217  }
218 
223  $this->setMwGlobals( 'wgContentHandlerTextFallback', 'serialize' );
224 
225  $content = new DummyContentForTesting( "hello world" );
226 
228  $this->assertEquals( $content->serialize(), $text );
229  }
230 
235  $this->setMwGlobals( 'wgContentHandlerTextFallback', 'ignore' );
236 
237  $content = new DummyContentForTesting( "hello world" );
238 
240  $this->assertNull( $text );
241  }
242 
243  public static function dataMakeContent() {
244  return [
245  [ 'hallo', 'Help:Test', null, null, CONTENT_MODEL_WIKITEXT, 'hallo', false ],
246  [ 'hallo', 'MediaWiki:Test.js', null, null, CONTENT_MODEL_JAVASCRIPT, 'hallo', false ],
247  [ serialize( 'hallo' ), 'Dummy:Test', null, null, "testing", 'hallo', false ],
248 
249  [
250  'hallo',
251  'Help:Test',
252  null,
255  'hallo',
256  false
257  ],
258  [
259  'hallo',
260  'MediaWiki:Test.js',
261  null,
264  'hallo',
265  false
266  ],
267  [ serialize( 'hallo' ), 'Dummy:Test', null, "testing", "testing", 'hallo', false ],
268 
269  [ 'hallo', 'Help:Test', CONTENT_MODEL_CSS, null, CONTENT_MODEL_CSS, 'hallo', false ],
270  [
271  'hallo',
272  'MediaWiki:Test.js',
274  null,
276  'hallo',
277  false
278  ],
279  [
280  serialize( 'hallo' ),
281  'Dummy:Test',
283  null,
285  serialize( 'hallo' ),
286  false
287  ],
288 
289  [ 'hallo', 'Help:Test', CONTENT_MODEL_WIKITEXT, "testing", null, null, true ],
290  [ 'hallo', 'MediaWiki:Test.js', CONTENT_MODEL_CSS, "testing", null, null, true ],
291  [ 'hallo', 'Dummy:Test', CONTENT_MODEL_JAVASCRIPT, "testing", null, null, true ],
292  ];
293  }
294 
299  public function testMakeContent( $data, $title, $modelId, $format,
300  $expectedModelId, $expectedNativeData, $shouldFail
301  ) {
303  MediaWikiServices::getInstance()->getLinkCache()->addBadLinkObj( $title );
304  try {
305  $content = ContentHandler::makeContent( $data, $title, $modelId, $format );
306 
307  if ( $shouldFail ) {
308  $this->fail( "ContentHandler::makeContent should have failed!" );
309  }
310 
311  $this->assertEquals( $expectedModelId, $content->getModel(), 'bad model id' );
312  $this->assertEquals( $expectedNativeData, $content->getNativeData(), 'bads native data' );
313  } catch ( MWException $ex ) {
314  if ( !$shouldFail ) {
315  $this->fail( "ContentHandler::makeContent failed unexpectedly: " . $ex->getMessage() );
316  } else {
317  // dummy, so we don't get the "test did not perform any assertions" message.
318  $this->assertTrue( true );
319  }
320  }
321  }
322 
329  public function testGetAutosummary() {
330  $this->setContentLang( 'en' );
331 
333  $title = Title::newFromText( 'Help:Test' );
334  // Create a new content object with no content
335  $newContent = ContentHandler::makeContent( '', $title, CONTENT_MODEL_WIKITEXT, null );
336  // first check, if we become a blank page created summary with the right bitmask
337  $autoSummary = $content->getAutosummary( null, $newContent, 97 );
338  $this->assertEquals( $autoSummary,
339  wfMessage( 'autosumm-newblank' )->inContentLanguage()->text() );
340  // now check, what we become with another bitmask
341  $autoSummary = $content->getAutosummary( null, $newContent, 92 );
342  $this->assertEquals( $autoSummary, '' );
343  }
344 
349  public function testGetChangeTag() {
350  $this->setMwGlobals( 'wgSoftwareTags', [ 'mw-contentmodelchange' => true ] );
351  $wikitextContentHandler = new DummyContentHandlerForTesting( CONTENT_MODEL_WIKITEXT );
352  // Create old content object with javascript content model
353  $oldContent = ContentHandler::makeContent( '', null, CONTENT_MODEL_JAVASCRIPT, null );
354  // Create new content object with wikitext content model
355  $newContent = ContentHandler::makeContent( '', null, CONTENT_MODEL_WIKITEXT, null );
356  // Get the tag for this edit
357  $tag = $wikitextContentHandler->getChangeTag( $oldContent, $newContent, EDIT_UPDATE );
358  $this->assertSame( $tag, 'mw-contentmodelchange' );
359  }
360 
364  public function testSupportsCategories() {
366  $this->assertTrue( $handler->supportsCategories(), 'content model supports categories' );
367  }
368 
372  public function testSupportsDirectEditing() {
374  $this->assertFalse( $handler->supportsDirectEditing(), 'direct editing is not supported' );
375  }
376 
377  public static function dummyHookHandler( $foo, &$text, $bar ) {
378  if ( $text === null || $text === false ) {
379  return false;
380  }
381 
382  $text = strtoupper( $text );
383 
384  return true;
385  }
386 
387  public function provideGetModelForID() {
388  return [
395  [ 'testing-callbacks', DummyContentHandlerForTesting::class ],
396  ];
397  }
398 
403  public function testGetModelForID( $modelId, $handlerClass ) {
405 
406  $this->assertInstanceOf( $handlerClass, $handler );
407  }
408 
412  public function testGetFieldsForSearchIndex() {
413  $searchEngine = $this->newSearchEngine();
414 
416 
417  $fields = $handler->getFieldsForSearchIndex( $searchEngine );
418 
419  $this->assertArrayHasKey( 'category', $fields );
420  $this->assertArrayHasKey( 'external_link', $fields );
421  $this->assertArrayHasKey( 'outgoing_link', $fields );
422  $this->assertArrayHasKey( 'template', $fields );
423  $this->assertArrayHasKey( 'content_model', $fields );
424  }
425 
426  private function newSearchEngine() {
427  $searchEngine = $this->getMockBuilder( SearchEngine::class )
428  ->getMock();
429 
430  $searchEngine->expects( $this->any() )
431  ->method( 'makeSearchFieldMapping' )
432  ->will( $this->returnCallback( function ( $name, $type ) {
434  } ) );
435 
436  return $searchEngine;
437  }
438 
442  public function testDataIndexFields() {
443  $mockEngine = $this->createMock( SearchEngine::class );
444  $title = Title::newFromText( 'Not_Main_Page', NS_MAIN );
445  $page = new WikiPage( $title );
446 
447  $this->setTemporaryHook( 'SearchDataForIndex',
448  function (
449  &$fields,
451  WikiPage $page,
454  ) {
455  $fields['testDataField'] = 'test content';
456  } );
457 
458  $output = $page->getContent()->getParserOutput( $title );
459  $data = $page->getContentHandler()->getDataForSearchIndex( $page, $output, $mockEngine );
460  $this->assertArrayHasKey( 'text', $data );
461  $this->assertArrayHasKey( 'text_bytes', $data );
462  $this->assertArrayHasKey( 'language', $data );
463  $this->assertArrayHasKey( 'testDataField', $data );
464  $this->assertEquals( 'test content', $data['testDataField'] );
465  $this->assertEquals( 'wikitext', $data['content_model'] );
466  }
467 
471  public function testParserOutputForIndexing() {
472  $title = Title::newFromText( 'Smithee', NS_MAIN );
473  $page = new WikiPage( $title );
474 
475  $out = $page->getContentHandler()->getParserOutputForIndexing( $page );
476  $this->assertInstanceOf( ParserOutput::class, $out );
477  $this->assertContains( 'one who smiths', $out->getRawText() );
478  }
479 
483  public function testGetContentModelsHook() {
484  $this->setTemporaryHook( 'GetContentModels', function ( &$models ) {
485  $models[] = 'Ferrari';
486  } );
487  $this->assertContains( 'Ferrari', ContentHandler::getContentModels() );
488  }
489 
494  $this->mergeMwGlobalArrayValue( 'wgHooks', [
495  'GetSlotDiffRenderer' => [],
496  ] );
497 
498  // test default renderer
499  $contentHandler = new WikitextContentHandler( CONTENT_MODEL_WIKITEXT );
500  $slotDiffRenderer = $contentHandler->getSlotDiffRenderer( RequestContext::getMain() );
501  $this->assertInstanceOf( TextSlotDiffRenderer::class, $slotDiffRenderer );
502  }
503 
507  public function testGetSlotDiffRenderer_bc() {
508  $this->mergeMwGlobalArrayValue( 'wgHooks', [
509  'GetSlotDiffRenderer' => [],
510  ] );
511 
512  // test B/C renderer
513  $customDifferenceEngine = $this->getMockBuilder( DifferenceEngine::class )
514  ->disableOriginalConstructor()
515  ->getMock();
516  // hack to track object identity across cloning
517  $customDifferenceEngine->objectId = 12345;
518  $customContentHandler = $this->getMockBuilder( ContentHandler::class )
519  ->setConstructorArgs( [ 'foo', [] ] )
520  ->setMethods( [ 'createDifferenceEngine' ] )
521  ->getMockForAbstractClass();
522  $customContentHandler->expects( $this->any() )
523  ->method( 'createDifferenceEngine' )
524  ->willReturn( $customDifferenceEngine );
526  $slotDiffRenderer = $customContentHandler->getSlotDiffRenderer( RequestContext::getMain() );
527  $this->assertInstanceOf( DifferenceEngineSlotDiffRenderer::class, $slotDiffRenderer );
528  $this->assertSame(
529  $customDifferenceEngine->objectId,
530  TestingAccessWrapper::newFromObject( $slotDiffRenderer )->differenceEngine->objectId
531  );
532  }
533 
537  public function testGetSlotDiffRenderer_nobc() {
538  $this->mergeMwGlobalArrayValue( 'wgHooks', [
539  'GetSlotDiffRenderer' => [],
540  ] );
541 
542  // test that B/C renderer does not get used when getSlotDiffRendererInternal is overridden
543  $customDifferenceEngine = $this->getMockBuilder( DifferenceEngine::class )
544  ->disableOriginalConstructor()
545  ->getMock();
546  $customSlotDiffRenderer = $this->getMockBuilder( SlotDiffRenderer::class )
547  ->disableOriginalConstructor()
548  ->getMockForAbstractClass();
549  $customContentHandler2 = $this->getMockBuilder( ContentHandler::class )
550  ->setConstructorArgs( [ 'bar', [] ] )
551  ->setMethods( [ 'createDifferenceEngine', 'getSlotDiffRendererInternal' ] )
552  ->getMockForAbstractClass();
553  $customContentHandler2->expects( $this->any() )
554  ->method( 'createDifferenceEngine' )
555  ->willReturn( $customDifferenceEngine );
556  $customContentHandler2->expects( $this->any() )
557  ->method( 'getSlotDiffRendererInternal' )
558  ->willReturn( $customSlotDiffRenderer );
560  $slotDiffRenderer = $customContentHandler2->getSlotDiffRenderer( RequestContext::getMain() );
561  $this->assertSame( $customSlotDiffRenderer, $slotDiffRenderer );
562  }
563 
567  public function testGetSlotDiffRenderer_hook() {
568  $this->mergeMwGlobalArrayValue( 'wgHooks', [
569  'GetSlotDiffRenderer' => [],
570  ] );
571 
572  // test that the hook handler takes precedence
573  $customDifferenceEngine = $this->getMockBuilder( DifferenceEngine::class )
574  ->disableOriginalConstructor()
575  ->getMock();
576  $customContentHandler = $this->getMockBuilder( ContentHandler::class )
577  ->setConstructorArgs( [ 'foo', [] ] )
578  ->setMethods( [ 'createDifferenceEngine' ] )
579  ->getMockForAbstractClass();
580  $customContentHandler->expects( $this->any() )
581  ->method( 'createDifferenceEngine' )
582  ->willReturn( $customDifferenceEngine );
585  $customSlotDiffRenderer = $this->getMockBuilder( SlotDiffRenderer::class )
586  ->disableOriginalConstructor()
587  ->getMockForAbstractClass();
588  $customContentHandler2 = $this->getMockBuilder( ContentHandler::class )
589  ->setConstructorArgs( [ 'bar', [] ] )
590  ->setMethods( [ 'createDifferenceEngine', 'getSlotDiffRendererInternal' ] )
591  ->getMockForAbstractClass();
592  $customContentHandler2->expects( $this->any() )
593  ->method( 'createDifferenceEngine' )
594  ->willReturn( $customDifferenceEngine );
595  $customContentHandler2->expects( $this->any() )
596  ->method( 'getSlotDiffRendererInternal' )
597  ->willReturn( $customSlotDiffRenderer );
600  $customSlotDiffRenderer2 = $this->getMockBuilder( SlotDiffRenderer::class )
601  ->disableOriginalConstructor()
602  ->getMockForAbstractClass();
603  $this->setTemporaryHook( 'GetSlotDiffRenderer',
604  function ( $handler, &$slotDiffRenderer ) use ( $customSlotDiffRenderer2 ) {
605  $slotDiffRenderer = $customSlotDiffRenderer2;
606  } );
607 
608  $slotDiffRenderer = $customContentHandler->getSlotDiffRenderer( RequestContext::getMain() );
609  $this->assertSame( $customSlotDiffRenderer2, $slotDiffRenderer );
610  $slotDiffRenderer = $customContentHandler2->getSlotDiffRenderer( RequestContext::getMain() );
611  $this->assertSame( $customSlotDiffRenderer2, $slotDiffRenderer );
612  }
613 
614 }
CONTENT_MODEL_JSON
const CONTENT_MODEL_JSON
Definition: Defines.php:239
ContentHandler
A content handler knows how do deal with a specific type of content on a wiki page.
Definition: ContentHandler.php:53
ContentHandler\getForModelID
static getForModelID( $modelId)
Returns the ContentHandler singleton for the given model ID.
Definition: ContentHandler.php:297
ContentHandlerTest\setUp
setUp()
Definition: ContentHandlerTest.php:11
Title\newFromText
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:280
ContentHandlerTest\testSupportsCategories
testSupportsCategories()
ContentHandler::supportsCategories.
Definition: ContentHandlerTest.php:364
ParserOutput
Definition: ParserOutput.php:25
false
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:187
ContentHandlerTest\testSupportsDirectEditing
testSupportsDirectEditing()
ContentHandler::supportsDirectEditing.
Definition: ContentHandlerTest.php:372
ContentHandlerTest\addDBDataOnce
addDBDataOnce()
Stub.
Definition: ContentHandlerTest.php:48
MediaWikiTestCase\mergeMwGlobalArrayValue
mergeMwGlobalArrayValue( $name, $values)
Merges the given values into a MW global array variable.
Definition: MediaWikiTestCase.php:901
$lang
if(!isset( $args[0])) $lang
Definition: testCompression.php:33
CONTENT_MODEL_CSS
const CONTENT_MODEL_CSS
Definition: Defines.php:237
ContentHandlerTest\testGetPageLanguage
testGetPageLanguage( $title, $expected)
dataGetPageLanguage ContentHandler::getPageLanguage
Definition: ContentHandlerTest.php:150
ContentHandlerTest\testGetFieldsForSearchIndex
testGetFieldsForSearchIndex()
ContentHandler::getFieldsForSearchIndex.
Definition: ContentHandlerTest.php:412
ContentHandlerTest\tearDown
tearDown()
Definition: ContentHandlerTest.php:41
ContentHandlerTest\testGetSlotDiffRenderer_hook
testGetSlotDiffRenderer_hook()
ContentHandler::getSlotDiffRenderer.
Definition: ContentHandlerTest.php:567
WikiPage
Class representing a MediaWiki article and history.
Definition: WikiPage.php:44
ContentHandlerTest\testGetChangeTag
testGetChangeTag()
Test software tag that is added when content model of the page changes ContentHandler::getChangeTag.
Definition: ContentHandlerTest.php:349
ContentHandlerTest\testGetAutosummary
testGetAutosummary()
ContentHandler::getAutosummary.
Definition: ContentHandlerTest.php:329
ContentHandlerTest\dataGetDefaultModelFor
static dataGetDefaultModelFor()
Definition: ContentHandlerTest.php:53
ContentHandler\getForTitle
static getForTitle(Title $title)
Returns the appropriate ContentHandler singleton for the given title.
Definition: ContentHandler.php:244
CONTENT_MODEL_WIKITEXT
const CONTENT_MODEL_WIKITEXT
Definition: Defines.php:235
MediaWikiTestCase\insertPage
insertPage( $pageName, $text='Sample page for unit test.', $namespace=null, User $user=null)
Insert a new page.
Definition: MediaWikiTestCase.php:1219
serialize
serialize()
Definition: ApiMessageTrait.php:131
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
ContentHandlerTest\dataGetPageLanguage
static dataGetPageLanguage()
Definition: ContentHandlerTest.php:130
NS_MAIN
const NS_MAIN
Definition: Defines.php:64
ContentHandlerTest\dataGetContentText_Null
static dataGetContentText_Null()
Definition: ContentHandlerTest.php:164
ContentHandler\getDefaultModelFor
static getDefaultModelFor(Title $title)
Returns the name of the default content model to be used for the page with the given title.
Definition: ContentHandler.php:182
MWException
MediaWiki exception.
Definition: MWException.php:26
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:964
ContentHandler\getContentModels
static getContentModels()
Definition: ContentHandler.php:372
MediaWikiTestCase\setMwGlobals
setMwGlobals( $pairs, $value=null)
Sets a global, maintaining a stashed version of the previous global to be restored in tearDown.
Definition: MediaWikiTestCase.php:706
ContentHandlerTest\testGetContentText_NonTextContent_ignore
testGetContentText_NonTextContent_ignore()
ContentHandler::getContentText.
Definition: ContentHandlerTest.php:234
MediaWikiTestCase
Definition: MediaWikiTestCase.php:16
ContentHandlerTest\testGetDefaultModelFor
testGetDefaultModelFor( $title, $expectedModelId)
dataGetDefaultModelFor ContentHandler::getDefaultModelFor
Definition: ContentHandlerTest.php:85
WikiPage\getContent
getContent( $audience=Revision::FOR_PUBLIC, User $user=null)
Get the content of the current revision.
Definition: WikiPage.php:798
wfGetLangObj
wfGetLangObj( $langcode=false)
Return a Language object from $langcode.
Definition: GlobalFunctions.php:1281
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
ContentHandlerTest\newSearchEngine
newSearchEngine()
Definition: ContentHandlerTest.php:426
$engine
the value to return A Title object or null for latest all implement SearchIndexField $engine
Definition: hooks.txt:2946
$output
$output
Definition: SyntaxHighlight.php:334
WikitextContent
Content object for wiki text pages.
Definition: WikitextContent.php:35
CONTENT_FORMAT_WIKITEXT
const CONTENT_FORMAT_WIKITEXT
Definition: Defines.php:250
ContentHandlerTest\testGetSlotDiffRenderer_nobc
testGetSlotDiffRenderer_nobc()
ContentHandler::getSlotDiffRenderer.
Definition: ContentHandlerTest.php:537
ContentHandlerTest\testGetContentText_NonTextContent_fail
testGetContentText_NonTextContent_fail()
ContentHandler::getContentText should have thrown an exception for non-text Content object MWExceptio...
Definition: ContentHandlerTest.php:211
ContentHandler\makeContent
static makeContent( $text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
Definition: ContentHandler.php:133
ContentHandlerTest\testGetLocalizedName
testGetLocalizedName( $id, $expected)
dataGetLocalizedName ContentHandler::getLocalizedName
Definition: ContentHandlerTest.php:115
ContentHandlerTest\testGetModelForID
testGetModelForID( $modelId, $handlerClass)
ContentHandler::getForModelID provideGetModelForID.
Definition: ContentHandlerTest.php:403
MediaWikiTestCase\setContentLang
setContentLang( $lang)
Definition: MediaWikiTestCase.php:1063
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:302
any
they could even be mouse clicks or menu items whatever suits your program You should also get your if any
Definition: COPYING.txt:326
EDIT_UPDATE
const EDIT_UPDATE
Definition: Defines.php:153
ContentHandler\getLocalizedName
static getLocalizedName( $name, Language $lang=null)
Returns the localized name for a given content model.
Definition: ContentHandler.php:359
WikitextContentHandler
Content handler for wiki text pages.
Definition: WikitextContentHandler.php:33
$wgLanguageCode
$wgLanguageCode
Site language code.
Definition: DefaultSettings.php:2942
ContentHandlerTest\testGetSlotDiffRenderer_default
testGetSlotDiffRenderer_default()
ContentHandler::getSlotDiffRenderer.
Definition: ContentHandlerTest.php:493
DummyContentForTesting
Definition: DummyContentForTesting.php:3
$handler
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 $handler
Definition: hooks.txt:813
RequestContext\getMain
static getMain()
Get the RequestContext object associated with the main request.
Definition: RequestContext.php:434
SearchEngine
Contain a class for special pages.
Definition: SearchEngine.php:34
text
This list may contain false positives That usually means there is additional text with links below the first Each row contains links to the first and second as well as the first line of the second redirect text
Definition: All_system_messages.txt:1267
DummySearchIndexFieldDefinition
Dummy implementation of SearchIndexFieldDefinition for testing purposes.
Definition: DummySearchIndexFieldDefinition.php:8
ContentHandlerTest\dataMakeContent
static dataMakeContent()
Definition: ContentHandlerTest.php:243
ContentHandler\getContentText
static getContentText(Content $content=null)
Convenience function for getting flat text from a Content object.
Definition: ContentHandler.php:83
ContentHandlerTest\testParserOutputForIndexing
testParserOutputForIndexing()
ContentHandler::getParserOutputForIndexing.
Definition: ContentHandlerTest.php:471
ContentHandlerTest\testGetContentText_Null
testGetContentText_Null( $contentHandlerTextFallback)
dataGetContentText_Null ContentHandler::getContentText
Definition: ContentHandlerTest.php:176
ContentHandlerTest\dataGetLocalizedName
static dataGetLocalizedName()
Definition: ContentHandlerTest.php:101
ContentHandlerTest\testDataIndexFields
testDataIndexFields()
ContentHandler::getDataForSearchIndex.
Definition: ContentHandlerTest.php:442
true
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
Definition: hooks.txt:2044
$content
$content
Definition: pageupdater.txt:72
ContentHandlerTest\dataGetContentText_TextContent
static dataGetContentText_TextContent()
Definition: ContentHandlerTest.php:185
ContentHandlerTest\testGetContentText_TextContent
testGetContentText_TextContent( $contentHandlerTextFallback)
dataGetContentText_TextContent ContentHandler::getContentText
Definition: ContentHandlerTest.php:197
class
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
Definition: maintenance.txt:52
CONTENT_MODEL_JAVASCRIPT
const CONTENT_MODEL_JAVASCRIPT
Definition: Defines.php:236
CONTENT_FORMAT_JAVASCRIPT
const CONTENT_FORMAT_JAVASCRIPT
Definition: Defines.php:252
ContentHandlerTest\testGetForTitle
testGetForTitle( $title, $expectedContentModel)
dataGetDefaultModelFor ContentHandler::getForTitle
Definition: ContentHandlerTest.php:94
MediaWikiTestCase\setTemporaryHook
setTemporaryHook( $hookName, $handler)
Create a temporary hook handler which will be reset by tearDown.
Definition: MediaWikiTestCase.php:2291
ContentHandlerTest\provideGetModelForID
provideGetModelForID()
Definition: ContentHandlerTest.php:387
MediaWikiServices
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
Definition: injection.txt:23
CONTENT_MODEL_TEXT
const CONTENT_MODEL_TEXT
Definition: Defines.php:238
wfMessage
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation use $formDescriptor instead default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "&lt
ContentHandlerTest
ContentHandler Database.
Definition: ContentHandlerTest.php:9
WikiPage\getContentHandler
getContentHandler()
Returns the ContentHandler instance to be used to deal with the content of this WikiPage.
Definition: WikiPage.php:268
ContentHandlerTest\testGetContentText_NonTextContent_serialize
testGetContentText_NonTextContent_serialize()
ContentHandler::getContentText.
Definition: ContentHandlerTest.php:222
ContentHandlerTest\testGetSlotDiffRenderer_bc
testGetSlotDiffRenderer_bc()
ContentHandler::getSlotDiffRenderer.
Definition: ContentHandlerTest.php:507
DummyContentHandlerForTesting
Definition: DummyContentHandlerForTesting.php:3
ContentHandlerTest\dummyHookHandler
static dummyHookHandler( $foo, &$text, $bar)
Definition: ContentHandlerTest.php:377
ContentHandlerTest\testGetContentModelsHook
testGetContentModelsHook()
ContentHandler::getContentModels.
Definition: ContentHandlerTest.php:483
ContentHandlerTest\testMakeContent
testMakeContent( $data, $title, $modelId, $format, $expectedModelId, $expectedNativeData, $shouldFail)
dataMakeContent ContentHandler::makeContent
Definition: ContentHandlerTest.php:299
$out
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 $out
Definition: hooks.txt:813
$type
$type
Definition: testCompression.php:48