X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fcontent%2FContentHandlerTest.php;h=1462c3627eb964e8f2e742f4a3d94f7034124ff7;hp=ee79ffa40f09ee5c687cc01ab419209f36f368d8;hb=dbad540cd37617879aff6f28ce9c016dd8049d4e;hpb=10d1b7d12b5d097413cd507740c5c71781c2580b diff --git a/tests/phpunit/includes/content/ContentHandlerTest.php b/tests/phpunit/includes/content/ContentHandlerTest.php index ee79ffa40f..1462c3627e 100644 --- a/tests/phpunit/includes/content/ContentHandlerTest.php +++ b/tests/phpunit/includes/content/ContentHandlerTest.php @@ -35,7 +35,7 @@ class ContentHandlerTest extends MediaWikiTestCase { ] ); // Reset namespace cache - MWNamespace::getCanonicalNamespaces( true ); + MWNamespace::clearCaches(); $wgContLang->resetNamespaces(); // And LinkCache MediaWikiServices::getInstance()->resetServiceForTesting( 'LinkCache' ); @@ -45,7 +45,7 @@ class ContentHandlerTest extends MediaWikiTestCase { global $wgContLang; // Reset namespace cache - MWNamespace::getCanonicalNamespaces( true ); + MWNamespace::clearCaches(); $wgContLang->resetNamespaces(); // And LinkCache MediaWikiServices::getInstance()->resetServiceForTesting( 'LinkCache' ); @@ -332,7 +332,9 @@ class ContentHandlerTest extends MediaWikiTestCase { } } - /* + /** + * @covers ContentHandler::getAutosummary + * * Test if we become a "Created blank page" summary from getAutoSummary if no Content added to * page. */ @@ -342,26 +344,49 @@ class ContentHandlerTest extends MediaWikiTestCase { $content = new DummyContentHandlerForTesting( CONTENT_MODEL_WIKITEXT ); $title = Title::newFromText( 'Help:Test' ); // Create a new content object with no content - $newContent = ContentHandler::makeContent( '', $title, null, null, CONTENT_MODEL_WIKITEXT ); + $newContent = ContentHandler::makeContent( '', $title, CONTENT_MODEL_WIKITEXT, null ); // first check, if we become a blank page created summary with the right bitmask $autoSummary = $content->getAutosummary( null, $newContent, 97 ); - $this->assertEquals( $autoSummary, 'Created blank page' ); + $this->assertEquals( $autoSummary, + wfMessage( 'autosumm-newblank' )->inContentLanguage()->text() ); // now check, what we become with another bitmask $autoSummary = $content->getAutosummary( null, $newContent, 92 ); $this->assertEquals( $autoSummary, '' ); } + /** + * Test software tag that is added when content model of the page changes + * @covers ContentHandler::getChangeTag + */ + public function testGetChangeTag() { + $this->setMwGlobals( 'wgSoftwareTags', [ 'mw-contentmodelchange' => true ] ); + $wikitextContentHandler = new DummyContentHandlerForTesting( CONTENT_MODEL_WIKITEXT ); + // Create old content object with javascript content model + $oldContent = ContentHandler::makeContent( '', null, CONTENT_MODEL_JAVASCRIPT, null ); + // Create new content object with wikitext content model + $newContent = ContentHandler::makeContent( '', null, CONTENT_MODEL_WIKITEXT, null ); + // Get the tag for this edit + $tag = $wikitextContentHandler->getChangeTag( $oldContent, $newContent, EDIT_UPDATE ); + $this->assertSame( $tag, 'mw-contentmodelchange' ); + } + /* public function testSupportsSections() { $this->markTestIncomplete( "not yet implemented" ); } */ + /** + * @covers ContentHandler::supportsCategories + */ public function testSupportsCategories() { $handler = new DummyContentHandlerForTesting( CONTENT_MODEL_WIKITEXT ); $this->assertTrue( $handler->supportsCategories(), 'content model supports categories' ); } + /** + * @covers ContentHandler::supportsDirectEditing + */ public function testSupportsDirectEditing() { $handler = new DummyContentHandlerForTesting( CONTENT_MODEL_JSON ); $this->assertFalse( $handler->supportsDirectEditing(), 'direct editing is not supported' ); @@ -390,6 +415,7 @@ class ContentHandlerTest extends MediaWikiTestCase { } /** + * @covers ContentHandler::getForModelID * @dataProvider provideGetModelForID */ public function testGetModelForID( $modelId, $handlerClass ) { @@ -398,6 +424,9 @@ class ContentHandlerTest extends MediaWikiTestCase { $this->assertInstanceOf( $handlerClass, $handler ); } + /** + * @covers ContentHandler::getFieldsForSearchIndex + */ public function testGetFieldsForSearchIndex() { $searchEngine = $this->newSearchEngine();