setShowExceptionDetails( true ); $objectFactory = new ObjectFactory( $this->getMockForAbstractClass( ContainerInterface::class ) ); $authority = $params['authority'] ?? $this->mockAnonUltimateAuthority(); $config = ( $params['config'] ?? [] ) + [ MainConfigNames::CanonicalServer => 'https://wiki.example.com', MainConfigNames::InternalServer => 'http://api.local:8080', MainConfigNames::RestPath => '/rest', MainConfigNames::ScriptPath => '/w', MainConfigNames::RightsUrl => 'https://rights.url', MainConfigNames::RightsText => 'your rights', MainConfigNames::EmergencyContact => 'admin@test.test', MainConfigNames::Sitename => 'Test Site', ]; $request = $params['request'] ?? new RequestData(); return new Router( $params['routeFiles'] ?? [ MW_INSTALL_PATH . '/tests/phpunit/unit/includes/Rest/testRoutes.json' ], $params['extraRoutes'] ?? [], $params['options'] ?? new ServiceOptions( Router::CONSTRUCTOR_OPTIONS, $config ), $params['cacheBag'] ?? new EmptyBagOStuff(), $params['responseFactory'] ?? $responseFactory, $params['basicAuth'] ?? new StaticBasicAuthorizer(), $params['authority'] ?? $authority, $params['objectFactory'] ?? $objectFactory, $params['validator'] ?? new Validator( $objectFactory, $request, $authority ), $params['errorReporter'] ?? new PHPErrorReporter(), $params['hookContainer'] ?? $this->createHookContainer(), $params['session'] ?? $this->getSession( true ) ); } /** * @since 1.43 * @param array $params Constructor parameters for Module and Router, as an associative array. * @return Module */ private function newModule( array $params ) { $objectFactory = new ObjectFactory( $this->getMockForAbstractClass( ContainerInterface::class ) ); $authority = $params['authority'] ?? $this->mockAnonUltimateAuthority(); $request = $params['request'] ?? new RequestData(); $module = $this->getMockBuilder( Module::class ) ->setConstructorArgs( [ $params['router'] ?? $this->newRouter( $params ), $params['pathPrefix'] ?? 'mock', $params['responseFactory'] ?? new ResponseFactory( [] ), $params['basicAuth'] ?? new StaticBasicAuthorizer(), $params['objectFactory'] ?? $objectFactory, $params['restValidator'] ?? new Validator( $objectFactory, $request, $authority ), $params['errorReporter'] ?? new PHPErrorReporter() ] ) ->onlyMethods( [] ) ->getMockForAbstractClass(); return $module; } }