Go to the documentation of this file.
31 $this->assertEquals( $expected,
$e->useOutputPage() );
37 [
false,
null,
null,
null ],
40 [
false,
null,
true,
null ],
41 [
false,
null,
null,
true ],
48 ->disableOriginalConstructor()
61 $this->assertEquals( $expected,
$e->useMessageCache() );
76 $this->assertTrue(
$e->isLoggable() );
88 $this->assertEquals( $expected,
$e->isCommandLine() );
106 new $exception_class()
108 $this->assertNotEquals(
false, $json,
109 "The $exception_class exception should be JSON serializable, got false." );
130 # Make sure we log a backtrace:
131 $this->
setMwGlobals( [
'wgLogExceptionBacktrace' =>
true ] );
136 $this->assertObjectHasAttribute( $key, $json,
137 "JSON serialized exception is missing key '$key'"
139 $this->assertInternalType( $expectedKeyType, $json->$key,
140 "JSON serialized key '$key' has type " . gettype( $json->$key )
141 .
" (expected: $expectedKeyType)."
152 [
'string', $exClass,
'id' ],
153 [
'string', $exClass,
'file' ],
154 [
'integer', $exClass,
'line' ],
155 [
'string', $exClass,
'message' ],
156 [
'null', $exClass,
'url' ],
157 # Backtrace only enabled with wgLogExceptionBacktrace = true
158 [
'array', $exClass,
'backtrace' ],
160 $testCases = array_merge( $testCases, $exTests );
172 $this->
setMwGlobals( [
'wgLogExceptionBacktrace' =>
true ] );
176 $this->assertObjectHasAttribute(
'backtrace', $json );
186 $this->
setMwGlobals( [
'wgLogExceptionBacktrace' =>
false ] );
190 $this->assertObjectNotHasAttribute(
'backtrace', $json );
testJsonserializeexceptionBacktracingDisabled()
Given wgLogExceptionBacktrace is false then serialized exception SHOULD NOT have a backtrace.
testJsonserializeexceptionBacktracingEnabled()
Given wgLogExceptionBacktrace is true then serialized exception SHOULD have a backtrace.
testIsLogable()
MWException::isLoggable.
testMwexceptionThrowing()
MWException MWException.
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 provideExceptionClasses()
global $wgCommandLineMode
static provideIsCommandLine()
testisCommandLine( $expected, $wgCommandLineMode)
provideIsCommandLine MWException::isCommandLine
foreach( $wgExtensionFunctions as $func) if(!defined( 'MW_NO_SESSION') &&! $wgCommandLineMode) if(! $wgCommandLineMode) $wgFullyInitialised
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not null
testUseMessageCache( $expected, $langObj)
provideUseMessageCache MWException::useMessageCache
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
static provideJsonSerializedKeys()
Returns test cases: exception class, key name, gettype()
testJsonserializeexceptionKeys( $expectedKeyType, $exClass, $key)
Lame JSON schema validation.
testUseOutputPage( $expected, $langObj, $wgFullyInitialised, $wgOut)
provideTextUseOutputPage MWException::useOutputPage
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
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
testJsonSerializeExceptions( $exception_class)
Verify the exception classes are JSON serializabe.
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
static jsonSerializeException( $e, $pretty=false, $escaping=0, $catcher=self::CAUGHT_BY_OTHER)
Serialize an Exception object to JSON.
provideTextUseOutputPage()