From 4769f44ea5b62e6bef40e8caabd30b9529d413d8 Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Wed, 23 Jan 2013 18:14:35 +0100 Subject: [PATCH] (bug 37209) Make TextContentTest and WikitextContentTest work in all cases Currently TextContentTest::testDeletionUpdates() and WikitextContentTest::testGetSecondaryDataUpdates() set a random page ID to pages that does not exist. This works in most cases, but when a method like Title::getLatestRevID() is called on these objects, it throws an excpection "LinkCache doesn't currently knows about this title." This happens e.g. when SemanticMediaWiki extension is installed. Intsead of setting a random page ID, really insert the page in the database before getting table updates so that it won't crash anymore. Change-Id: I489c406f78897bc38ac41d8d599b778b47b30021 --- tests/phpunit/includes/content/TextContentTest.php | 11 ++++++++--- .../phpunit/includes/content/WikitextContentTest.php | 9 +++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/tests/phpunit/includes/content/TextContentTest.php b/tests/phpunit/includes/content/TextContentTest.php index 3501aec44a..ca387a243d 100644 --- a/tests/phpunit/includes/content/TextContentTest.php +++ b/tests/phpunit/includes/content/TextContentTest.php @@ -349,12 +349,15 @@ class TextContentTest extends MediaWikiLangTestCase { * @dataProvider dataGetDeletionUpdates */ public function testDeletionUpdates( $title, $model, $text, $expectedStuff ) { - $title = Title::newFromText( $title ); - $title->resetArticleID( 2342 ); //dummy id. fine as long as we don't try to execute the updates! + $ns = $this->getDefaultWikitextNS(); + $title = Title::newFromText( $title, $ns ); $content = ContentHandler::makeContent( $text, $title, $model ); - $updates = $content->getDeletionUpdates( WikiPage::factory( $title ) ); + $page = WikiPage::factory( $title ); + $page->doEditContent( $content, '' ); + + $updates = $content->getDeletionUpdates( $page ); // make updates accessible by class name foreach ( $updates as $update ) { @@ -377,6 +380,8 @@ class TextContentTest extends MediaWikiLangTestCase { $this->assertEquals( $value, $v, "unexpected value for field $field in instance of $class" ); } } + + $page->doDeleteArticle( '' ); } public static function provideConvert() { diff --git a/tests/phpunit/includes/content/WikitextContentTest.php b/tests/phpunit/includes/content/WikitextContentTest.php index b76e9aae30..7cf473ea78 100644 --- a/tests/phpunit/includes/content/WikitextContentTest.php +++ b/tests/phpunit/includes/content/WikitextContentTest.php @@ -69,11 +69,14 @@ more stuff * @group Database */ public function testGetSecondaryDataUpdates( $title, $model, $text, $expectedStuff ) { - $title = Title::newFromText( $title ); - $title->resetArticleID( 2342 ); //dummy id. fine as long as we don't try to execute the updates! + $ns = $this->getDefaultWikitextNS(); + $title = Title::newFromText( $title, $ns ); $content = ContentHandler::makeContent( $text, $title, $model ); + $page = WikiPage::factory( $title ); + $page->doEditContent( $content, '' ); + $updates = $content->getSecondaryDataUpdates( $title ); // make updates accessible by class name @@ -92,6 +95,8 @@ more stuff $this->assertEquals( $value, $v, "unexpected value for field $field in instance of $class" ); } } + + $page->doDeleteArticle( '' ); } public static function dataGetSection() { -- 2.20.1