CONTENT_MODEL_CSS => 'CssContentHandler',
CONTENT_MODEL_TEXT => 'TextContentHandler',
'testing' => 'DummyContentHandlerForTesting',
- 'testing-callbacks' => function( $modelId ) {
+ 'testing-callbacks' => function ( $modelId ) {
return new DummyContentHandlerForTesting( $modelId );
}
],
] );
// Reset namespace cache
- MWNamespace::getCanonicalNamespaces( true );
+ MWNamespace::clearCaches();
$wgContLang->resetNamespaces();
// And LinkCache
MediaWikiServices::getInstance()->resetServiceForTesting( 'LinkCache' );
global $wgContLang;
// Reset namespace cache
- MWNamespace::getCanonicalNamespaces( true );
+ MWNamespace::clearCaches();
$wgContLang->resetNamespaces();
// And LinkCache
MediaWikiServices::getInstance()->resetServiceForTesting( 'LinkCache' );
$this->assertFalse( $handler->supportsDirectEditing(), 'direct editing is not supported' );
}
- /**
- * @covers ContentHandler::runLegacyHooks
- */
- public function testRunLegacyHooks() {
- Hooks::register( 'testRunLegacyHooks', __CLASS__ . '::dummyHookHandler' );
-
- $content = new WikitextContent( 'test text' );
- $ok = ContentHandler::runLegacyHooks(
- 'testRunLegacyHooks',
- [ 'foo', &$content, 'bar' ]
- );
-
- $this->assertTrue( $ok, "runLegacyHooks should have returned true" );
- $this->assertEquals( "TEST TEXT", $content->getNativeData() );
- }
-
public static function dummyHookHandler( $foo, &$text, $bar ) {
if ( $text === null || $text === false ) {
return false;
$this->assertArrayHasKey( 'external_link', $fields );
$this->assertArrayHasKey( 'outgoing_link', $fields );
$this->assertArrayHasKey( 'template', $fields );
+ $this->assertArrayHasKey( 'content_model', $fields );
}
private function newSearchEngine() {
$searchEngine->expects( $this->any() )
->method( 'makeSearchFieldMapping' )
- ->will( $this->returnCallback( function( $name, $type ) {
+ ->will( $this->returnCallback( function ( $name, $type ) {
return new DummySearchIndexFieldDefinition( $name, $type );
} ) );
* @covers ContentHandler::getDataForSearchIndex
*/
public function testDataIndexFields() {
- $mockEngine = $this->getMock( 'SearchEngine' );
+ $mockEngine = $this->createMock( 'SearchEngine' );
$title = Title::newFromText( 'Not_Main_Page', NS_MAIN );
$page = new WikiPage( $title );
$this->setTemporaryHook( 'SearchDataForIndex',
- function ( &$fields, ContentHandler $handler, WikiPage $page, ParserOutput $output,
- SearchEngine $engine ) {
+ function (
+ &$fields,
+ ContentHandler $handler,
+ WikiPage $page,
+ ParserOutput $output,
+ SearchEngine $engine
+ ) {
$fields['testDataField'] = 'test content';
} );
$this->assertArrayHasKey( 'language', $data );
$this->assertArrayHasKey( 'testDataField', $data );
$this->assertEquals( 'test content', $data['testDataField'] );
+ $this->assertEquals( 'wikitext', $data['content_model'] );
}
/**
$this->assertContains( 'one who smiths', $out->getRawText() );
}
+ /**
+ * @covers ContentHandler::getContentModels
+ */
+ public function testGetContentModelsHook() {
+ $this->setTemporaryHook( 'GetContentModels', function ( &$models ) {
+ $models[] = 'Ferrari';
+ } );
+ $this->assertContains( 'Ferrari', ContentHandler::getContentModels() );
+ }
}