X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fcontent%2FTextContentTest.php;h=b5480911df1700b4bc96d4b4ca2dc2bf78682d07;hb=1de7117197761961736ea43b237599569eee93a2;hp=160149335254e8c573f74c5a517a0d46b5988248;hpb=99781586a6b639e67b11c18e2cb31378a53d6e0c;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/content/TextContentTest.php b/tests/phpunit/includes/content/TextContentTest.php index 1601493352..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() { @@ -454,7 +443,7 @@ class TextContentTest extends MediaWikiLangTestCase { if ( $expectedNative === false ) { $this->assertFalse( $converted, "conversion to $model was expected to fail!" ); } else { - $this->assertInstanceOf( 'Content', $converted ); + $this->assertInstanceOf( Content::class, $converted ); $this->assertEquals( $expectedNative, $converted->getNativeData() ); } }