wiki.techinc.nl/tests/phpunit/includes/WikiPageTest_ContentHandlerUseDB.php
umherirrender ff3485ec99 Tests: Use more setMwGlobals
Change some tests to use setMwGlobals to have restoring of globals after
the test.
This also removes some save/restore code, which is not needed, due to
the automatically restoring on tearDown with setMwGlobals.

Change-Id: I8d2ac9f6cc14f0bd4ee8eb851c09f2e71babc6e0
2013-03-21 20:35:44 +01:00

48 lines
1.7 KiB
PHP

<?php
/**
* @group ContentHandler
* @group Database
* ^--- important, causes temporary tables to be used instead of the real database
*/
class WikiPageTest_ContentHandlerUseDB extends WikiPageTest {
function setUp() {
parent::setUp();
$this->setMwGlobals( 'wgContentHandlerUseDB', false );
$dbw = wfGetDB( DB_MASTER );
$page_table = $dbw->tableName( 'page' );
$revision_table = $dbw->tableName( 'revision' );
$archive_table = $dbw->tableName( 'archive' );
if ( $dbw->fieldExists( $page_table, 'page_content_model' ) ) {
$dbw->query( "alter table $page_table drop column page_content_model" );
$dbw->query( "alter table $revision_table drop column rev_content_model" );
$dbw->query( "alter table $revision_table drop column rev_content_format" );
$dbw->query( "alter table $archive_table drop column ar_content_model" );
$dbw->query( "alter table $archive_table drop column ar_content_format" );
}
}
public function testGetContentModel() {
$page = $this->createPage( "WikiPageTest_testGetContentModel", "some text", CONTENT_MODEL_JAVASCRIPT );
$page = new WikiPage( $page->getTitle() );
// NOTE: since the content model is not recorded in the database,
// we expect to get the default, namely CONTENT_MODEL_WIKITEXT
$this->assertEquals( CONTENT_MODEL_WIKITEXT, $page->getContentModel() );
}
public function testGetContentHandler() {
$page = $this->createPage( "WikiPageTest_testGetContentHandler", "some text", CONTENT_MODEL_JAVASCRIPT );
// NOTE: since the content model is not recorded in the database,
// we expect to get the default, namely CONTENT_MODEL_WIKITEXT
$page = new WikiPage( $page->getTitle() );
$this->assertEquals( 'WikitextContentHandler', get_class( $page->getContentHandler() ) );
}
}