(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
This commit is contained in:
Alexandre Emsenhuber 2013-01-23 18:14:35 +01:00
parent 5904133e57
commit 4769f44ea5
2 changed files with 15 additions and 5 deletions

View file

@ -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() {

View file

@ -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() {