40 $contLang = Language::factory(
'en' );
42 'wgLanguageCode' =>
'en',
43 'wgContLang' => $contLang,
46 $this->testParser =
new Parser();
47 $this->testParser->Options( ParserOptions::newFromUserAndLang(
new User, $contLang ) );
49 # initialize parser output
50 $this->testParser->clearState();
52 # Needs a title to do magic word stuff
53 $title = Title::newFromText(
'Tests' );
54 # Else it needs a db connection just to check if it's a redirect
55 # (when deciding the page language).
56 $title->mRedirect =
false;
58 $this->testParser->setTitle( $title );
67 for ( $i = 1; $i <= $num; $i++ ) {
88 # ############## TESTS #############################################
90 # - those got copy pasted, we can probably make them cleaner
91 # - tests are lacking useful messages
161 # ############## HELPERS ############################################
180 # Initialize parser timestamp as year 2010 at 12h34 56s.
181 # month and day are given by the caller ($value). Month < 12!
189 sprintf(
'2010%02d%02d123456', $month,
$value )
192 # please keep the following commented line of code. It helps debugging.
195 # format expectation and test it
196 $expected = sprintf( $format,
$value );
205 $this->testParser->Options()->setTimestamp( $ts );
206 $this->testParser->mRevisionTimestamp = $ts;
215 if ( in_array( $magic, $this->expectedAsInteger ) ) {
216 $expected = (int)$expected;
219 # Generate a message for the assertion
220 $msg = sprintf(
"Magic %s should be <%s:%s>",
228 $this->testParser->getVariableValue( $magic ),
Database Parser::getVariableValue.
assertZeroPadded( $magic, $value)
assertion helper expecting a magic output which is zero padded
setParserTS( $ts)
helper to set the parser timestamp and revision timestamp
static createProviderUpTo( $num)
testRevisiondayIsUnPadded( $day)
provideDays
setUp()
setup a basic parser object
testLocaldaytwoIsZeroPadded( $day)
provideDays
testCurrentdayIsUnPadded( $day)
provideDays
$expectedAsInteger
An array of magicword returned as type integer by the parser They are usually returned as a string fo...
testLocalmonthoneIsUnPadded( $month)
provideMonths
testLocaldayIsUnPadded( $day)
provideDays
testRevisiondaytwoIsZeroPadded( $day)
provideDays
testCurrentdaytwoIsZeroPadded( $day)
provideDays
testRevisionmonthIsZeroPadded( $month)
provideMonths
assertMagic( $expected, $magic)
Assertion helper to test a magic variable output.
testCurrentmonthIsZeroPadded( $month)
provideMonths
assertMagicPadding( $magic, $value, $format)
Main assertion helper for magic variables padding.
testRevisionmonthoneIsUnPadded( $month)
provideMonths
testLocalmonthIsZeroPadded( $month)
provideMonths
assertUnPadded( $magic, $value)
assertion helper expecting a magic output which is unpadded
testCurrentmonthoneIsUnPadded( $month)
provideMonths
PHP Parser - Processes wiki markup (which uses a more user-friendly syntax, such as "[[link]]" for ma...
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
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