MediaWiki
REL1_24
|
00001 <?php 00002 00008 class RevisionTestContentHandlerUseDB 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( 00039 in_array( 'rev_timestamp', $fields ), 00040 'missing rev_timestamp in list of fields' 00041 ); 00042 $this->assertTrue( in_array( 'rev_user', $fields ), 'missing rev_user in list of fields' ); 00043 00044 $this->assertFalse( 00045 in_array( 'rev_content_model', $fields ), 00046 'missing rev_content_model in list of fields' 00047 ); 00048 $this->assertFalse( 00049 in_array( 'rev_content_format', $fields ), 00050 'missing rev_content_format in list of fields' 00051 ); 00052 } 00053 00057 public function testGetContentModel() { 00058 try { 00059 $this->makeRevision( array( 'text' => 'hello hello.', 00060 'content_model' => CONTENT_MODEL_JAVASCRIPT ) ); 00061 00062 $this->fail( "Creating JavaScript content on a wikitext page should fail with " 00063 . "\$wgContentHandlerUseDB disabled" ); 00064 } catch ( MWException $ex ) { 00065 $this->assertTrue( true ); // ok 00066 } 00067 } 00068 00072 public function testGetContentFormat() { 00073 try { 00074 // @todo change this to test failure on using a non-standard (but supported) format 00075 // for a content model supported in the given location. As of 1.21, there are 00076 // no alternative formats for any of the standard content models that could be 00077 // used for this though. 00078 00079 $this->makeRevision( array( 'text' => 'hello hello.', 00080 'content_model' => CONTENT_MODEL_JAVASCRIPT, 00081 'content_format' => 'text/javascript' ) ); 00082 00083 $this->fail( "Creating JavaScript content on a wikitext page should fail with " 00084 . "\$wgContentHandlerUseDB disabled" ); 00085 } catch ( MWException $ex ) { 00086 $this->assertTrue( true ); // ok 00087 } 00088 } 00089 }