Fix almost all occurences of the following sniffs: Generic.CodeAnalysis.UselessOverridingMethod.Found Generic.Formatting.NoSpaceAfterCast.SpaceFound Generic.Functions.FunctionCallArgumentSpacing.SpaceBeforeComma Generic.Functions.OpeningFunctionBraceKernighanRitchie.BraceOnNewLine Generic.PHP.LowerCaseConstant.Found PSR2.Classes.PropertyDeclaration.ScopeMissing PSR2.Files.EndFileNewline.TooMany PSR2.Methods.MethodDeclaration.StaticBeforeVisibility Change-Id: I96aacef5bafe5a2bca659744fba1380999cfc37d
62 lines
2 KiB
PHP
62 lines
2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @group ContentHandler
|
|
* @group Database
|
|
* ^--- important, causes temporary tables to be used instead of the real database
|
|
*/
|
|
class WikiPageTest_ContentHandlerUseDB extends WikiPageTest {
|
|
var $saveContentHandlerNoDB = null;
|
|
|
|
function setUp() {
|
|
global $wgContentHandlerUseDB;
|
|
|
|
parent::setUp();
|
|
|
|
$this->saveContentHandlerNoDB = $wgContentHandlerUseDB;
|
|
|
|
$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" );
|
|
}
|
|
}
|
|
|
|
function tearDown() {
|
|
global $wgContentHandlerUseDB;
|
|
|
|
$wgContentHandlerUseDB = $this->saveContentHandlerNoDB;
|
|
|
|
parent::tearDown();
|
|
}
|
|
|
|
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() );
|
|
}
|
|
|
|
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() ) );
|
|
}
|
|
|
|
}
|