13 $factoryConstructor =
new ReflectionMethod(
'ParserFactory',
'__construct' );
14 $instanceConstructor =
new ReflectionMethod(
'Parser',
'__construct' );
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?' );
23 $factoryConstructor =
new ReflectionMethod(
'ParserFactory',
'__construct' );
25 foreach ( $factoryConstructor->getParameters()
as $param ) {
27 if (
$type ===
'array' ) {
28 $val = [
'porcupines will tell me your secrets' .
count( $mocks ) ];
29 } elseif ( class_exists(
$type ) || interface_exists(
$type ) ) {
30 $val = $this->createMock(
$type );
31 } elseif (
$type ===
'' ) {
33 $val =
'I will de-quill them first' .
count( $mocks );
35 $this->fail(
"Unrecognized parameter type $type in ParserFactory constructor" );
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] );
52 $this->assertCount( 0, $mocks,
'Not all arguments to the ParserFactory constructor were ' .
53 'found in Parser member variables' );