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()
48 $fields = Revision
::selectFields();
50 $this->assertTrue( in_array( 'rev_id', $fields ), 'missing rev_id in list of fields');
51 $this->assertTrue( in_array( 'rev_page', $fields ), 'missing rev_page in list of fields');
52 $this->assertTrue( in_array( 'rev_timestamp', $fields ), 'missing rev_timestamp in list of fields');
53 $this->assertTrue( in_array( 'rev_user', $fields ), 'missing rev_user in list of fields');
55 $this->assertFalse( in_array( 'rev_content_model', $fields ), 'missing rev_content_model in list of fields');
56 $this->assertFalse( in_array( 'rev_content_format', $fields ), 'missing rev_content_format in list of fields');
60 * @covers Revision::getContentModel
62 public function testGetContentModel()
64 $orig = $this->makeRevision( array( 'text' => 'hello hello.', 'content_model' => CONTENT_MODEL_JAVASCRIPT
) );
65 $rev = Revision
::newFromId( $orig->getId() );
67 //NOTE: database fields for the content_model are disabled, so the model name is not retained.
68 // We expect to get the default here instead of what was suppleid when creating the revision.
69 $this->assertEquals( CONTENT_MODEL_WIKITEXT
, $rev->getContentModel() );
74 * @covers Revision::getContentFormat
76 public function testGetContentFormat()
78 $orig = $this->makeRevision( array( 'text' => 'hello hello.', 'content_model' => CONTENT_MODEL_JAVASCRIPT
, 'content_format' => 'text/javascript' ) );
79 $rev = Revision
::newFromId( $orig->getId() );
81 $this->assertEquals( 'text/x-wiki', $rev->getContentFormat() );