4 * @group ContentHandler
6 * ^--- important, causes temporary tables to be used instead of the real database
8 class RevisionTest_ContentHandlerUseDB
extends RevisionStorageTest
{
9 var $saveContentHandlerNoDB = null;
12 global $wgContentHandlerUseDB;
14 $this->saveContentHandlerNoDB
= $wgContentHandlerUseDB;
16 $wgContentHandlerUseDB = false;
18 $dbw = wfGetDB( DB_MASTER
);
20 $page_table = $dbw->tableName( 'page' );
21 $revision_table = $dbw->tableName( 'revision' );
22 $archive_table = $dbw->tableName( 'archive' );
24 if ( $dbw->fieldExists( $page_table, 'page_content_model' ) ) {
25 $dbw->query( "alter table $page_table drop column page_content_model" );
26 $dbw->query( "alter table $revision_table drop column rev_content_model" );
27 $dbw->query( "alter table $revision_table drop column rev_content_format" );
28 $dbw->query( "alter table $archive_table drop column ar_content_model" );
29 $dbw->query( "alter table $archive_table drop column ar_content_format" );
36 global $wgContentHandlerUseDB;
40 $wgContentHandlerUseDB = $this->saveContentHandlerNoDB
;
44 * @covers Revision::selectFields
46 public function testSelectFields() {
47 $fields = Revision
::selectFields();
49 $this->assertTrue( in_array( 'rev_id', $fields ), 'missing rev_id in list of fields');
50 $this->assertTrue( in_array( 'rev_page', $fields ), 'missing rev_page in list of fields');
51 $this->assertTrue( in_array( 'rev_timestamp', $fields ), 'missing rev_timestamp in list of fields');
52 $this->assertTrue( in_array( 'rev_user', $fields ), 'missing rev_user in list of fields');
54 $this->assertFalse( in_array( 'rev_content_model', $fields ), 'missing rev_content_model in list of fields');
55 $this->assertFalse( in_array( 'rev_content_format', $fields ), 'missing rev_content_format in list of fields');
59 * @covers Revision::getContentModel
61 public function testGetContentModel() {
63 $this->makeRevision( array( 'text' => 'hello hello.',
64 'content_model' => CONTENT_MODEL_JAVASCRIPT
) );
66 $this->fail( "Creating JavaScript content on a wikitext page should fail with "
67 . "\$wgContentHandlerUseDB disabled" );
68 } catch ( MWException
$ex ) {
69 $this->assertTrue( true ); // ok
75 * @covers Revision::getContentFormat
77 public function testGetContentFormat() {
79 //@todo: change this to test failure on using a non-standard (but supported) format
80 // for a content model supported in the given location. As of 1.21, there are
81 // no alternative formats for any of the standard content models that could be
82 // used for this though.
84 $this->makeRevision( array( 'text' => 'hello hello.',
85 'content_model' => CONTENT_MODEL_JAVASCRIPT
,
86 'content_format' => 'text/javascript' ) );
88 $this->fail( "Creating JavaScript content on a wikitext page should fail with "
89 . "\$wgContentHandlerUseDB disabled" );
90 } catch ( MWException
$ex ) {
91 $this->assertTrue( true ); // ok