<?php
+use MediaWiki\MediaWikiServices;
+
/**
* @group ContentHandler
* @group Database
protected function setUp() {
parent::setUp();
+ // trigger purging of all page related tables
+ $this->tablesUsed[] = 'page';
+ $this->tablesUsed[] = 'revision';
+
// Anon user
$user = new User();
$user->setName( '127.0.0.1' );
CONTENT_MODEL_CSS,
CONTENT_MODEL_JAVASCRIPT,
],
- 'wgUseTidy' => false,
+ 'wgTidyConfig' => [ 'driver' => 'disabled' ],
'wgCapitalLinks' => true,
'wgHooks' => [], // bypass hook ContentGetParserOutput that force custom rendering
] );
* @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(
* @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 );
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",
[]
],
* @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 );
$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" );
}
}
- $page->doDeleteArticle( '' );
+ // make phpunit happy even if $expectedStuff was empty
+ $this->assertTrue( true );
}
public static function provideConvert() {