MediaWiki  REL1_22
WikiPageTest_ContentHandlerUseDB.php
Go to the documentation of this file.
00001 <?php
00002 
00008 class WikiPageTest_ContentHandlerUseDB extends WikiPageTest {
00009 
00010     protected function setUp() {
00011         parent::setUp();
00012         $this->setMwGlobals( 'wgContentHandlerUseDB', false );
00013 
00014         $dbw = wfGetDB( DB_MASTER );
00015 
00016         $page_table = $dbw->tableName( 'page' );
00017         $revision_table = $dbw->tableName( 'revision' );
00018         $archive_table = $dbw->tableName( 'archive' );
00019 
00020         if ( $dbw->fieldExists( $page_table, 'page_content_model' ) ) {
00021             $dbw->query( "alter table $page_table drop column page_content_model" );
00022             $dbw->query( "alter table $revision_table drop column rev_content_model" );
00023             $dbw->query( "alter table $revision_table drop column rev_content_format" );
00024             $dbw->query( "alter table $archive_table drop column ar_content_model" );
00025             $dbw->query( "alter table $archive_table drop column ar_content_format" );
00026         }
00027     }
00028 
00032     public function testGetContentModel() {
00033         $page = $this->createPage( "WikiPageTest_testGetContentModel", "some text", CONTENT_MODEL_JAVASCRIPT );
00034 
00035         $page = new WikiPage( $page->getTitle() );
00036 
00037         // NOTE: since the content model is not recorded in the database,
00038         //       we expect to get the default, namely CONTENT_MODEL_WIKITEXT
00039         $this->assertEquals( CONTENT_MODEL_WIKITEXT, $page->getContentModel() );
00040     }
00041 
00045     public function testGetContentHandler() {
00046         $page = $this->createPage( "WikiPageTest_testGetContentHandler", "some text", CONTENT_MODEL_JAVASCRIPT );
00047 
00048         // NOTE: since the content model is not recorded in the database,
00049         //       we expect to get the default, namely CONTENT_MODEL_WIKITEXT
00050         $page = new WikiPage( $page->getTitle() );
00051         $this->assertEquals( 'WikitextContentHandler', get_class( $page->getContentHandler() ) );
00052     }
00053 }