Go to the documentation of this file.
41 'wgLanguageCode' =>
'en',
42 'wgContLang' => $contLang,
45 $this->testParser =
new Parser();
48 # initialize parser output
49 $this->testParser->clearState();
51 # Needs a title to do magic word stuff
53 # Else it needs a db connection just to check if it's a redirect
54 # (when deciding the page language).
57 $this->testParser->setTitle(
$title );
66 for ( $i = 1; $i <= $num; $i++ ) {
87 # ############## TESTS #############################################
89 # - those got copy pasted, we can probably make them cleaner
90 # - tests are lacking useful messages
160 # ############## HELPERS ############################################
179 # Initialize parser timestamp as year 2010 at 12h34 56s.
180 # month and day are given by the caller ($value). Month < 12!
188 sprintf(
'2010%02d%02d123456', $month,
$value )
191 # please keep the following commented line of code. It helps debugging.
194 # format expectation and test it
195 $expected = sprintf( $format,
$value );
204 $this->testParser->Options()->setTimestamp( $ts );
205 $this->testParser->mRevisionTimestamp = $ts;
214 if ( in_array( $magic, $this->expectedAsInteger ) ) {
215 $expected = (int)$expected;
218 # Generate a message for the assertion
219 $msg = sprintf(
"Magic %s should be <%s:%s>",
227 $this->testParser->getVariableValue( $magic ),
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
assertZeroPadded( $magic, $value)
assertion helper expecting a magic output which is zero padded
testCurrentdaytwoIsZeroPadded( $day)
@dataProvider provideDays
setParserTS( $ts)
helper to set the parser timestamp and revision timestamp
testLocalmonthIsZeroPadded( $month)
@dataProvider provideMonths
testRevisionmonthoneIsUnPadded( $month)
@dataProvider provideMonths
testLocaldayIsUnPadded( $day)
@dataProvider provideDays
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
$expectedAsInteger
An array of magicword returned as type integer by the parser They are usually returned as a string fo...
namespace and then decline to actually register it file or subcat img or subcat $title
static newFromUserAndLang(User $user, Language $lang)
Get a ParserOptions object from a given user and language.
assertMagic( $expected, $magic)
Assertion helper to test a magic variable output.
testCurrentmonthIsZeroPadded( $month)
@dataProvider provideMonths
setUp()
setup a basic parser object
testRevisionmonthIsZeroPadded( $month)
@dataProvider provideMonths
testCurrentmonthoneIsUnPadded( $month)
@dataProvider provideMonths
testRevisiondaytwoIsZeroPadded( $day)
@dataProvider provideDays
testLocaldaytwoIsZeroPadded( $day)
@dataProvider provideDays
testCurrentdayIsUnPadded( $day)
@dataProvider provideDays
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
assertMagicPadding( $magic, $value, $format)
Main assertion helper for magic variables padding.
static createProviderUpTo( $num)
static factory( $code)
Get a cached or new language object for a given language code.
assertUnPadded( $magic, $value)
assertion helper expecting a magic output which is unpadded
testRevisiondayIsUnPadded( $day)
@dataProvider provideDays
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
testLocalmonthoneIsUnPadded( $month)
@dataProvider provideMonths