MediaWiki REL1_33
ParserFactoryTest.php
Go to the documentation of this file.
1<?php
2
12 public function testConstructorArgNum() {
13 $factoryConstructor = new ReflectionMethod( 'ParserFactory', '__construct' );
14 $instanceConstructor = new ReflectionMethod( 'Parser', '__construct' );
15 // Subtract one for the ParserFactory itself
16 $this->assertSame( $instanceConstructor->getNumberOfParameters() - 1,
17 $factoryConstructor->getNumberOfParameters(),
18 'Parser and ParserFactory constructors have an inconsistent number of parameters. ' .
19 'Did you add a parameter to one and not the other?' );
20 }
21
22 public function testAllArgumentsWerePassed() {
23 $factoryConstructor = new ReflectionMethod( 'ParserFactory', '__construct' );
24 $mocks = [];
25 foreach ( $factoryConstructor->getParameters() as $param ) {
26 $type = (string)$param->getType();
27 if ( $type === 'array' ) {
28 $val = [ 'porcupines will tell me your secrets' . count( $mocks ) ];
30 $val = $this->createMock( $type );
31 } elseif ( $type === '' ) {
32 // Optimistically assume a string is okay
33 $val = 'I will de-quill them first' . count( $mocks );
34 } else {
35 $this->fail( "Unrecognized parameter type $type in ParserFactory constructor" );
36 }
37 $mocks[] = $val;
38 }
39
40 $factory = new ParserFactory( ...$mocks );
41 $parser = $factory->create();
42
43 foreach ( ( new ReflectionObject( $parser ) )->getProperties() as $prop ) {
44 $prop->setAccessible( true );
45 foreach ( $mocks as $idx => $mock ) {
46 if ( $prop->getValue( $parser ) === $mock ) {
47 unset( $mocks[$idx] );
48 }
49 }
50 }
51
52 $this->assertCount( 0, $mocks, 'Not all arguments to the ParserFactory constructor were ' .
53 'found in Parser member variables' );
54 }
55}
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
testConstructorArgNum()
For backwards compatibility, all parameters to the parser constructor are optional and default to the...
see documentation in includes Linker php for Linker::makeImageLink or false for current used if you return false $parser
Definition hooks.txt:1834
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible true was required This is the default since MediaWiki *some string
Definition hooks.txt:181