30 $this->assertEquals( $expected,
$e->useOutputPage() );
36 [
false, null, null, null ],
39 [
false, null,
true, null ],
40 [
false, null, null,
true ],
46 return $this->getMockBuilder(
'Language' )
47 ->disableOriginalConstructor()
60 $this->assertEquals( $expected,
$e->useMessageCache() );
75 $this->assertTrue(
$e->isLoggable() );
84 'wgExceptionHooks' => $wgExceptionHooks,
87 $this->assertEquals( $expectedReturn,
$e->runHooks(
$name,
$args ) );
92 [ null, null, null, null ],
93 [ [],
'name', [], null ],
94 [ [
'name' =>
false ],
'name', [], null ],
96 [
'mockHook' => [
'MWExceptionTest::mockHook' ] ],
97 'mockHook', [],
'YAY.[]'
100 [
'mockHook' => [
'MWExceptionTest::mockHook' ] ],
101 'mockHook', [
'a' ],
'YAY.{"1":"a"}'
104 [
'mockHook' => [
'MWExceptionTest::mockHook' ] ],
105 'mockHook', [ null ], null
114 $args = func_get_args();
116 return '$caller not instance of MWException';
119 if ( array_key_exists( 1,
$args ) &&
$args[1] === null ) {
122 return 'YAY.' . json_encode(
$args );
134 $this->assertEquals( $expected,
$e->isCommandLine() );
152 new $exception_class()
154 $this->assertNotEquals(
false, $json,
155 "The $exception_class exception should be JSON serializable, got false." );
177 # Make sure we log a backtrace:
178 $this->
setMwGlobals( [
'wgLogExceptionBacktrace' =>
true ] );
183 $this->assertObjectHasAttribute( $key, $json,
184 "JSON serialized exception is missing key '$key'"
186 $this->assertInternalType( $expectedKeyType, $json->$key,
187 "JSON serialized key '$key' has type " . gettype( $json->$key )
188 .
" (expected: $expectedKeyType)."
197 foreach ( [
'Exception',
'MWException' ]
as $exClass ) {
199 [
'string', $exClass,
'id' ],
200 [
'string', $exClass,
'file' ],
201 [
'integer', $exClass,
'line' ],
202 [
'string', $exClass,
'message' ],
203 [
'null', $exClass,
'url' ],
204 # Backtrace only enabled with wgLogExceptionBacktrace = true
205 [
'array', $exClass,
'backtrace' ],
207 $testCases = array_merge( $testCases, $exTests );
219 $this->
setMwGlobals( [
'wgLogExceptionBacktrace' =>
true ] );
223 $this->assertObjectHasAttribute(
'backtrace', $json );
233 $this->
setMwGlobals( [
'wgLogExceptionBacktrace' =>
false ] );
237 $this->assertObjectNotHasAttribute(
'backtrace', $json );
testisCommandLine($expected, $wgCommandLineMode)
provideIsCommandLine MWException::isCommandLine
static provideIsCommandLine()
processing should stop and the error should be shown to the user * false
testJsonserializeexceptionKeys($expectedKeyType, $exClass, $key)
Lame JSON schema validation.
static provideExceptionClasses()
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException'returning false will NOT prevent logging $e
testIsLogable()
MWException::isLoggable.
provideTextUseOutputPage()
static mockHook()
Used in conjunction with provideRunHooks and testRunHooks as a mock callback for a hook...
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 just before the function returns a value If you return true
global $wgCommandLineMode
testJsonserializeexceptionBacktracingEnabled()
Given wgLogExceptionBacktrace is true then serialized exception SHOULD have a backtrace.
testUseMessageCache($expected, $langObj)
provideUseMessageCache MWException::useMessageCache
testJsonserializeexceptionBacktracingDisabled()
Given wgLogExceptionBacktrace is false then serialized exception SHOULD NOT have a backtrace...
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
testUseOutputPage($expected, $langObj, $wgFullyInitialised, $wgOut)
provideTextUseOutputPage MWException::useOutputPage
testRunHooks($wgExceptionHooks, $name, $args, $expectedReturn)
provideRunHooks MWException::runHooks
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
static provideJsonSerializedKeys()
Returns test cases: exception class, key name, gettype()
testMwexceptionThrowing()
MWException.
testJsonSerializeExceptions($exception_class)
Verify the exception classes are JSON serializabe.
static jsonSerializeException($e, $pretty=false, $escaping=0)
Serialize an Exception object to JSON.
Allows to change the fields on the form that will be generated $name