MediaWiki  REL1_31
ParserPreloadTest.php
Go to the documentation of this file.
1 <?php
34  private $testParser;
42  private $title;
43 
44  protected function setUp() {
46 
47  parent::setUp();
48  $this->testParserOptions = ParserOptions::newFromUserAndLang( new User, $wgContLang );
49 
50  $this->testParser = new Parser();
51  $this->testParser->Options( $this->testParserOptions );
52  $this->testParser->clearState();
53 
54  $this->title = Title::newFromText( 'Preload Test' );
55  }
56 
57  protected function tearDown() {
58  parent::tearDown();
59 
60  unset( $this->testParser );
61  unset( $this->title );
62  }
63 
64  public function testPreloadSimpleText() {
65  $this->assertPreloaded( 'simple', 'simple' );
66  }
67 
68  public function testPreloadedPreIsUnstripped() {
69  $this->assertPreloaded(
70  '<pre>monospaced</pre>',
71  '<pre>monospaced</pre>',
72  '<pre> in preloaded text must be unstripped (T29467)'
73  );
74  }
75 
76  public function testPreloadedNowikiIsUnstripped() {
77  $this->assertPreloaded(
78  '<nowiki>[[Dummy title]]</nowiki>',
79  '<nowiki>[[Dummy title]]</nowiki>',
80  '<nowiki> in preloaded text must be unstripped (T29467)'
81  );
82  }
83 
84  protected function assertPreloaded( $expected, $text, $msg = '' ) {
85  $this->assertEquals(
86  $expected,
87  $this->testParser->getPreloadText(
88  $text,
89  $this->title,
90  $this->testParserOptions
91  ),
92  $msg
93  );
94  }
95 }
ParserOptions
Set options of the Parser.
Definition: ParserOptions.php:40
Title\newFromText
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:273
ParserPreloadTest\tearDown
tearDown()
Definition: ParserPreloadTest.php:57
ParserPreloadTest\testPreloadedNowikiIsUnstripped
testPreloadedNowikiIsUnstripped()
Definition: ParserPreloadTest.php:76
php
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:37
ParserPreloadTest\setUp
setUp()
Definition: ParserPreloadTest.php:44
ParserPreloadTest\$testParserOptions
ParserOptions $testParserOptions
Definition: ParserPreloadTest.php:38
ParserOptions\newFromUserAndLang
static newFromUserAndLang(User $user, Language $lang)
Get a ParserOptions object from a given user and language.
Definition: ParserOptions.php:992
MediaWikiTestCase
Definition: MediaWikiTestCase.php:17
title
title
Definition: parserTests.txt:219
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:95
ParserPreloadTest\assertPreloaded
assertPreloaded( $expected, $text, $msg='')
Definition: ParserPreloadTest.php:84
ParserPreloadTest
Basic tests for Parser::getPreloadText.
Definition: ParserPreloadTest.php:30
ParserPreloadTest\testPreloadedPreIsUnstripped
testPreloadedPreIsUnstripped()
Definition: ParserPreloadTest.php:68
Parser
PHP Parser - Processes wiki markup (which uses a more user-friendly syntax, such as "[[link]]" for ma...
Definition: Parser.php:70
ParserPreloadTest\$testParser
Parser $testParser
Definition: ParserPreloadTest.php:34
Title
Represents a title within MediaWiki.
Definition: Title.php:39
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:53
ParserPreloadTest\$title
Title $title
Definition: ParserPreloadTest.php:42
ParserPreloadTest\testPreloadSimpleText
testPreloadSimpleText()
Definition: ParserPreloadTest.php:64
$wgContLang
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the content language as $wgContLang
Definition: design.txt:57