1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
<?php
/**
* @group ContentHandler
* @group Database
* ^--- important, causes temporary tables to be used instead of the real database
*/
class WikiPageTestContentHandlerUseDB extends WikiPageTest {
protected function setUp() {
parent::setUp();
$this->setMwGlobals( 'wgContentHandlerUseDB', false );
$dbw = wfGetDB( DB_MASTER );
$page_table = $dbw->tableName( 'page' );
$revision_table = $dbw->tableName( 'revision' );
$archive_table = $dbw->tableName( 'archive' );
if ( $dbw->fieldExists( $page_table, 'page_content_model' ) ) {
$dbw->query( "alter table $page_table drop column page_content_model" );
$dbw->query( "alter table $revision_table drop column rev_content_model" );
$dbw->query( "alter table $revision_table drop column rev_content_format" );
$dbw->query( "alter table $archive_table drop column ar_content_model" );
$dbw->query( "alter table $archive_table drop column ar_content_format" );
}
}
/**
* @covers WikiPage::getContentModel
*/
public function testGetContentModel() {
$page = $this->createPage(
"WikiPageTest_testGetContentModel",
"some text",
CONTENT_MODEL_JAVASCRIPT
);
$page = new WikiPage( $page->getTitle() );
// NOTE: since the content model is not recorded in the database,
// we expect to get the default, namely CONTENT_MODEL_WIKITEXT
$this->assertEquals( CONTENT_MODEL_WIKITEXT, $page->getContentModel() );
}
/**
* @covers WikiPage::getContentHandler
*/
public function testGetContentHandler() {
$page = $this->createPage(
"WikiPageTest_testGetContentHandler",
"some text",
CONTENT_MODEL_JAVASCRIPT
);
// NOTE: since the content model is not recorded in the database,
// we expect to get the default, namely CONTENT_MODEL_WIKITEXT
$page = new WikiPage( $page->getTitle() );
$this->assertEquals( 'WikitextContentHandler', get_class( $page->getContentHandler() ) );
}
}
|