X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fcontent%2FTextContentTest.php;h=a8904940f648379a45015340a246450474b16799;hp=b5480911df1700b4bc96d4b4ca2dc2bf78682d07;hb=62c36e82cf424f6ef51b524b2da41ff798111d83;hpb=3f59cb9f3a53ad28f8a95fe299c5de6abd24b453 diff --git a/tests/phpunit/includes/content/TextContentTest.php b/tests/phpunit/includes/content/TextContentTest.php index b5480911df..a8904940f6 100644 --- a/tests/phpunit/includes/content/TextContentTest.php +++ b/tests/phpunit/includes/content/TextContentTest.php @@ -1,5 +1,7 @@ tablesUsed[] = 'page'; + $this->tablesUsed[] = 'revision'; + // Anon user $user = new User(); $user->setName( '127.0.0.1' ); @@ -26,7 +32,7 @@ class TextContentTest extends MediaWikiLangTestCase { CONTENT_MODEL_CSS, CONTENT_MODEL_JAVASCRIPT, ], - 'wgUseTidy' => false, + 'wgTidyConfig' => [ 'driver' => 'disabled' ], 'wgCapitalLinks' => true, 'wgHooks' => [], // bypass hook ContentGetParserOutput that force custom rendering ] ); @@ -115,9 +121,8 @@ class TextContentTest extends MediaWikiLangTestCase { * @covers TextContent::preSaveTransform */ public function testPreSaveTransform( $text, $expected ) { - global $wgContLang; - - $options = ParserOptions::newFromUserAndLang( $this->context->getUser(), $wgContLang ); + $options = ParserOptions::newFromUserAndLang( $this->context->getUser(), + MediaWikiServices::getInstance()->getContentLanguage() ); $content = $this->newContent( $text ); $content = $content->preSaveTransform( @@ -143,8 +148,8 @@ class TextContentTest extends MediaWikiLangTestCase { * @covers TextContent::preloadTransform */ public function testPreloadTransform( $text, $expected ) { - global $wgContLang; - $options = ParserOptions::newFromUserAndLang( $this->context->getUser(), $wgContLang ); + $options = ParserOptions::newFromUserAndLang( $this->context->getUser(), + MediaWikiServices::getInstance()->getContentLanguage() ); $content = $this->newContent( $text ); $content = $content->preloadTransform( $this->context->getTitle(), $options ); @@ -197,16 +202,6 @@ class TextContentTest extends MediaWikiLangTestCase { 'any', true ], - [ 'Foo', - null, - 'comma', - false - ], - [ 'Foo, bar', - null, - 'comma', - false - ], ]; } @@ -361,11 +356,11 @@ class TextContentTest extends MediaWikiLangTestCase { public static function dataGetDeletionUpdates() { return [ - [ "TextContentTest_testGetSecondaryDataUpdates_1", + [ CONTENT_MODEL_TEXT, "hello ''world''\n", [] ], - [ "TextContentTest_testGetSecondaryDataUpdates_2", + [ CONTENT_MODEL_TEXT, "hello [[world test 21344]]\n", [] ], @@ -377,13 +372,11 @@ class TextContentTest extends MediaWikiLangTestCase { * @dataProvider dataGetDeletionUpdates * @covers TextContent::getDeletionUpdates */ - public function testDeletionUpdates( $title, $model, $text, $expectedStuff ) { - $ns = $this->getDefaultWikitextNS(); - $title = Title::newFromText( $title, $ns ); + public function testDeletionUpdates( $model, $text, $expectedStuff ) { + $page = $this->getNonexistingTestPage( get_class( $this ) . '-' . $this->getName() ); + $title = $page->getTitle(); $content = ContentHandler::makeContent( $text, $title, $model ); - - $page = WikiPage::factory( $title ); $page->doEditContent( $content, '' ); $updates = $content->getDeletionUpdates( $page ); @@ -394,11 +387,6 @@ class TextContentTest extends MediaWikiLangTestCase { $updates[$class] = $update; } - if ( !$expectedStuff ) { - $this->assertTrue( true ); // make phpunit happy - return; - } - foreach ( $expectedStuff as $class => $fieldValues ) { $this->assertArrayHasKey( $class, $updates, "missing an update of type $class" ); @@ -410,7 +398,8 @@ class TextContentTest extends MediaWikiLangTestCase { } } - $page->doDeleteArticle( '' ); + // make phpunit happy even if $expectedStuff was empty + $this->assertTrue( true ); } public static function provideConvert() {