MediaWiki  REL1_22
RevisionStorageTest_ContentHandlerUseDB.php
Go to the documentation of this file.
00001 <?php
00002 
00008 class RevisionTest_ContentHandlerUseDB extends RevisionStorageTest {
00009 
00010     protected function setUp() {
00011         $this->setMwGlobals( 'wgContentHandlerUseDB', false );
00012 
00013         $dbw = wfGetDB( DB_MASTER );
00014 
00015         $page_table = $dbw->tableName( 'page' );
00016         $revision_table = $dbw->tableName( 'revision' );
00017         $archive_table = $dbw->tableName( 'archive' );
00018 
00019         if ( $dbw->fieldExists( $page_table, 'page_content_model' ) ) {
00020             $dbw->query( "alter table $page_table drop column page_content_model" );
00021             $dbw->query( "alter table $revision_table drop column rev_content_model" );
00022             $dbw->query( "alter table $revision_table drop column rev_content_format" );
00023             $dbw->query( "alter table $archive_table drop column ar_content_model" );
00024             $dbw->query( "alter table $archive_table drop column ar_content_format" );
00025         }
00026 
00027         parent::setUp();
00028     }
00029 
00033     public function testSelectFields() {
00034         $fields = Revision::selectFields();
00035 
00036         $this->assertTrue( in_array( 'rev_id', $fields ), 'missing rev_id in list of fields' );
00037         $this->assertTrue( in_array( 'rev_page', $fields ), 'missing rev_page in list of fields' );
00038         $this->assertTrue( in_array( 'rev_timestamp', $fields ), 'missing rev_timestamp in list of fields' );
00039         $this->assertTrue( in_array( 'rev_user', $fields ), 'missing rev_user in list of fields' );
00040 
00041         $this->assertFalse( in_array( 'rev_content_model', $fields ), 'missing rev_content_model in list of fields' );
00042         $this->assertFalse( in_array( 'rev_content_format', $fields ), 'missing rev_content_format in list of fields' );
00043     }
00044 
00048     public function testGetContentModel() {
00049         try {
00050             $this->makeRevision( array( 'text' => 'hello hello.',
00051                 'content_model' => CONTENT_MODEL_JAVASCRIPT ) );
00052 
00053             $this->fail( "Creating JavaScript content on a wikitext page should fail with "
00054                 . "\$wgContentHandlerUseDB disabled" );
00055         } catch ( MWException $ex ) {
00056             $this->assertTrue( true ); // ok
00057         }
00058     }
00059 
00060 
00064     public function testGetContentFormat() {
00065         try {
00066             // @todo change this to test failure on using a non-standard (but supported) format
00067             //       for a content model supported in the given location. As of 1.21, there are
00068             //       no alternative formats for any of the standard content models that could be
00069             //       used for this though.
00070 
00071             $this->makeRevision( array( 'text' => 'hello hello.',
00072                 'content_model' => CONTENT_MODEL_JAVASCRIPT,
00073                 'content_format' => 'text/javascript' ) );
00074 
00075             $this->fail( "Creating JavaScript content on a wikitext page should fail with "
00076                 . "\$wgContentHandlerUseDB disabled" );
00077         } catch ( MWException $ex ) {
00078             $this->assertTrue( true ); // ok
00079         }
00080     }
00081 }