MediaWiki  1.28.3
WikiPageTestContentHandlerUseDB.php
Go to the documentation of this file.
1 <?php
2 
9 
10  protected function setUp() {
11  parent::setUp();
12  $this->setMwGlobals( 'wgContentHandlerUseDB', false );
13 
14  $dbw = wfGetDB( DB_MASTER );
15 
16  $page_table = $dbw->tableName( 'page' );
17  $revision_table = $dbw->tableName( 'revision' );
18  $archive_table = $dbw->tableName( 'archive' );
19 
20  if ( $dbw->fieldExists( $page_table, 'page_content_model' ) ) {
21  $dbw->query( "alter table $page_table drop column page_content_model" );
22  $dbw->query( "alter table $revision_table drop column rev_content_model" );
23  $dbw->query( "alter table $revision_table drop column rev_content_format" );
24  $dbw->query( "alter table $archive_table drop column ar_content_model" );
25  $dbw->query( "alter table $archive_table drop column ar_content_format" );
26  }
27  }
28 
32  public function testGetContentModel() {
33  $page = $this->createPage(
34  "WikiPageTest_testGetContentModel",
35  "some text",
37  );
38 
39  $page = new WikiPage( $page->getTitle() );
40 
41  // NOTE: since the content model is not recorded in the database,
42  // we expect to get the default, namely CONTENT_MODEL_WIKITEXT
43  $this->assertEquals( CONTENT_MODEL_WIKITEXT, $page->getContentModel() );
44  }
45 
49  public function testGetContentHandler() {
50  $page = $this->createPage(
51  "WikiPageTest_testGetContentHandler",
52  "some text",
54  );
55 
56  // NOTE: since the content model is not recorded in the database,
57  // we expect to get the default, namely CONTENT_MODEL_WIKITEXT
58  $page = new WikiPage( $page->getTitle() );
59  $this->assertEquals( 'WikitextContentHandler', get_class( $page->getContentHandler() ) );
60  }
61 }
testGetContentModel()
WikiPage::getContentModel.
wfGetDB($db, $groups=[], $wiki=false)
Get a Database object.
const CONTENT_MODEL_WIKITEXT
Definition: Defines.php:239
const DB_MASTER
Definition: defines.php:23
testGetContentHandler()
WikiPage::getContentHandler.
CONTENT_MODEL_JAVASCRIPT
Uploads have to be specially set up to be secure.
ContentHandler Database ^— important, causes temporary tables to be used instead of the real databas...
Class representing a MediaWiki article and history.
Definition: WikiPage.php:32
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
ContentHandler Database ^— important, causes temporary tables to be used instead of the real databas...
Definition: WikiPageTest.php:9
setMwGlobals($pairs, $value=null)
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached $page
Definition: hooks.txt:2495
createPage($page, $text, $model=null)