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