MediaWiki
REL1_30
RevisionStorageTestContentHandlerUseDB.php
Go to the documentation of this file.
1
<?php
2
8
class
RevisionTestContentHandlerUseDB
extends
RevisionStorageTest
{
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(
39
in_array(
'rev_timestamp'
, $fields ),
40
'missing rev_timestamp in list of fields'
41
);
42
$this->assertTrue( in_array(
'rev_user'
, $fields ),
'missing rev_user in list of fields'
);
43
44
$this->assertFalse(
45
in_array(
'rev_content_model'
, $fields ),
46
'missing rev_content_model in list of fields'
47
);
48
$this->assertFalse(
49
in_array(
'rev_content_format'
, $fields ),
50
'missing rev_content_format in list of fields'
51
);
52
}
53
57
public
function
testGetContentModel
() {
58
try
{
59
$this->
makeRevision
( [
'text'
=>
'hello hello.'
,
60
'content_model'
=>
CONTENT_MODEL_JAVASCRIPT
] );
61
62
$this->fail(
"Creating JavaScript content on a wikitext page should fail with "
63
.
"\$wgContentHandlerUseDB disabled"
);
64
}
catch
(
MWException
$ex ) {
65
$this->assertTrue(
true
);
// ok
66
}
67
}
68
72
public
function
testGetContentFormat
() {
73
try
{
74
// @todo change this to test failure on using a non-standard (but supported) format
75
// for a content model supported in the given location. As of 1.21, there are
76
// no alternative formats for any of the standard content models that could be
77
// used for this though.
78
79
$this->
makeRevision
( [
'text'
=>
'hello hello.'
,
80
'content_model'
=>
CONTENT_MODEL_JAVASCRIPT
,
81
'content_format'
=>
'text/javascript'
] );
82
83
$this->fail(
"Creating JavaScript content on a wikitext page should fail with "
84
.
"\$wgContentHandlerUseDB disabled"
);
85
}
catch
(
MWException
$ex ) {
86
$this->assertTrue(
true
);
// ok
87
}
88
}
89
}
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition
GlobalFunctions.php:2857
MWException
MediaWiki exception.
Definition
MWException.php:26
MediaWikiTestCase\setMwGlobals
setMwGlobals( $pairs, $value=null)
Sets a global, maintaining a stashed version of the previous global to be restored in tearDown.
Definition
MediaWikiTestCase.php:672
RevisionStorageTest
Test class for Revision storage.
Definition
RevisionStorageTest.php:13
RevisionStorageTest\makeRevision
makeRevision( $props=null)
Definition
RevisionStorageTest.php:80
RevisionTestContentHandlerUseDB
ContentHandler Database ^— important, causes temporary tables to be used instead of the real database...
Definition
RevisionStorageTestContentHandlerUseDB.php:8
RevisionTestContentHandlerUseDB\setUp
setUp()
Definition
RevisionStorageTestContentHandlerUseDB.php:10
RevisionTestContentHandlerUseDB\testGetContentModel
testGetContentModel()
Revision::getContentModel.
Definition
RevisionStorageTestContentHandlerUseDB.php:57
RevisionTestContentHandlerUseDB\testSelectFields
testSelectFields()
Revision::selectFields.
Definition
RevisionStorageTestContentHandlerUseDB.php:33
RevisionTestContentHandlerUseDB\testGetContentFormat
testGetContentFormat()
Revision::getContentFormat.
Definition
RevisionStorageTestContentHandlerUseDB.php:72
Revision\selectFields
static selectFields()
Return the list of revision fields that should be selected to create a new revision.
Definition
Revision.php:452
CONTENT_MODEL_JAVASCRIPT
const CONTENT_MODEL_JAVASCRIPT
Definition
Defines.php:237
DB_MASTER
const DB_MASTER
Definition
defines.php:26
tests
phpunit
includes
RevisionStorageTestContentHandlerUseDB.php
Generated on Mon Nov 25 2024 15:43:56 for MediaWiki by
1.10.0