MediaWiki  1.23.0
RevisionStorageTest_ContentHandlerUseDB.php
Go to the documentation of this file.
1 <?php
2 
9 
10  protected function setUp() {
11  $this->setMwGlobals( 'wgContentHandlerUseDB', false );
12 
13  $dbw = wfGetDB( DB_MASTER );
14 
15  $page_table = $dbw->tableName( 'page' );
16  $revision_table = $dbw->tableName( 'revision' );
17  $archive_table = $dbw->tableName( 'archive' );
18 
19  if ( $dbw->fieldExists( $page_table, 'page_content_model' ) ) {
20  $dbw->query( "alter table $page_table drop column page_content_model" );
21  $dbw->query( "alter table $revision_table drop column rev_content_model" );
22  $dbw->query( "alter table $revision_table drop column rev_content_format" );
23  $dbw->query( "alter table $archive_table drop column ar_content_model" );
24  $dbw->query( "alter table $archive_table drop column ar_content_format" );
25  }
26 
27  parent::setUp();
28  }
29 
33  public function testSelectFields() {
34  $fields = Revision::selectFields();
35 
36  $this->assertTrue( in_array( 'rev_id', $fields ), 'missing rev_id in list of fields' );
37  $this->assertTrue( in_array( 'rev_page', $fields ), 'missing rev_page in list of fields' );
38  $this->assertTrue( in_array( 'rev_timestamp', $fields ), 'missing rev_timestamp in list of fields' );
39  $this->assertTrue( in_array( 'rev_user', $fields ), 'missing rev_user in list of fields' );
40 
41  $this->assertFalse( in_array( 'rev_content_model', $fields ), 'missing rev_content_model in list of fields' );
42  $this->assertFalse( in_array( 'rev_content_format', $fields ), 'missing rev_content_format in list of fields' );
43  }
44 
48  public function testGetContentModel() {
49  try {
50  $this->makeRevision( array( 'text' => 'hello hello.',
51  'content_model' => CONTENT_MODEL_JAVASCRIPT ) );
52 
53  $this->fail( "Creating JavaScript content on a wikitext page should fail with "
54  . "\$wgContentHandlerUseDB disabled" );
55  } catch ( MWException $ex ) {
56  $this->assertTrue( true ); // ok
57  }
58  }
59 
63  public function testGetContentFormat() {
64  try {
65  // @todo change this to test failure on using a non-standard (but supported) format
66  // for a content model supported in the given location. As of 1.21, there are
67  // no alternative formats for any of the standard content models that could be
68  // used for this though.
69 
70  $this->makeRevision( array( 'text' => 'hello hello.',
71  'content_model' => CONTENT_MODEL_JAVASCRIPT,
72  'content_format' => 'text/javascript' ) );
73 
74  $this->fail( "Creating JavaScript content on a wikitext page should fail with "
75  . "\$wgContentHandlerUseDB disabled" );
76  } catch ( MWException $ex ) {
77  $this->assertTrue( true ); // ok
78  }
79  }
80 }
DB_MASTER
const DB_MASTER
Definition: Defines.php:56
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
RevisionTest_ContentHandlerUseDB\testGetContentFormat
testGetContentFormat()
@covers Revision::getContentFormat
Definition: RevisionStorageTest_ContentHandlerUseDB.php:63
wfGetDB
& wfGetDB( $db, $groups=array(), $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:3650
fail
as a message key or array as accepted by ApiBase::dieUsageMsg after processing request parameters Return false to let the request fail
Definition: hooks.txt:375
RevisionTest_ContentHandlerUseDB\setUp
setUp()
Definition: RevisionStorageTest_ContentHandlerUseDB.php:10
MWException
MediaWiki exception.
Definition: MWException.php:26
MediaWikiTestCase\setMwGlobals
setMwGlobals( $pairs, $value=null)
Definition: MediaWikiTestCase.php:302
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
RevisionTest_ContentHandlerUseDB\testGetContentModel
testGetContentModel()
@covers Revision::getContentModel
Definition: RevisionStorageTest_ContentHandlerUseDB.php:48
RevisionTest_ContentHandlerUseDB
@group ContentHandler @group Database ^— important, causes temporary tables to be used instead of the...
Definition: RevisionStorageTest_ContentHandlerUseDB.php:8
RevisionTest_ContentHandlerUseDB\testSelectFields
testSelectFields()
@covers Revision::selectFields
Definition: RevisionStorageTest_ContentHandlerUseDB.php:33
RevisionStorageTest\makeRevision
makeRevision( $props=null)
Definition: RevisionStorageTest.php:73
CONTENT_MODEL_JAVASCRIPT
const CONTENT_MODEL_JAVASCRIPT
Definition: Defines.php:284
Revision\selectFields
static selectFields()
Return the list of revision fields that should be selected to create a new revision.
Definition: Revision.php:405
RevisionStorageTest
Test class for Revision storage.
Definition: RevisionStorageTest.php:13