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() );
87 $this->assertEquals( $expected,
$e->isCommandLine() );
104 $json = MWExceptionHandler::jsonSerializeException(
105 new $exception_class()
107 $this->assertNotEquals(
false, $json,
108 "The $exception_class exception should be JSON serializable, got false." );
129 # Make sure we log a backtrace:
130 $this->
setMwGlobals( [
'wgLogExceptionBacktrace' =>
true ] );
133 MWExceptionHandler::jsonSerializeException(
new $exClass() )
135 $this->assertObjectHasAttribute( $key, $json,
136 "JSON serialized exception is missing key '$key'"
138 $this->assertInternalType( $expectedKeyType, $json->$key,
139 "JSON serialized key '$key' has type " . gettype( $json->$key )
140 .
" (expected: $expectedKeyType)."
149 foreach ( [
'Exception',
'MWException' ] as $exClass ) {
151 [
'string', $exClass,
'id' ],
152 [
'string', $exClass,
'file' ],
153 [
'integer', $exClass,
'line' ],
154 [
'string', $exClass,
'message' ],
155 [
'null', $exClass,
'url' ],
156 # Backtrace only enabled with wgLogExceptionBacktrace = true
157 [
'array', $exClass,
'backtrace' ],
159 $testCases = array_merge( $testCases, $exTests );
171 $this->
setMwGlobals( [
'wgLogExceptionBacktrace' =>
true ] );
173 MWExceptionHandler::jsonSerializeException(
new Exception() )
175 $this->assertObjectHasAttribute(
'backtrace', $json );
185 $this->
setMwGlobals( [
'wgLogExceptionBacktrace' =>
false ] );
187 MWExceptionHandler::jsonSerializeException(
new Exception() )
189 $this->assertObjectNotHasAttribute(
'backtrace', $json );
global $wgCommandLineMode
foreach( $wgExtensionFunctions as $func) if(!defined('MW_NO_SESSION') &&! $wgCommandLineMode) if(! $wgCommandLineMode) $wgFullyInitialised
testisCommandLine( $expected, $wgCommandLineMode)
provideIsCommandLine MWException::isCommandLine
provideTextUseOutputPage()
testMwexceptionThrowing()
MWException.
testUseMessageCache( $expected, $langObj)
provideUseMessageCache MWException::useMessageCache
static provideIsCommandLine()
testJsonserializeexceptionBacktracingEnabled()
Given wgLogExceptionBacktrace is true then serialized exception SHOULD have a backtrace.
testIsLogable()
MWException::isLoggable.
static provideJsonSerializedKeys()
Returns test cases: exception class, key name, gettype()
testJsonserializeexceptionBacktracingDisabled()
Given wgLogExceptionBacktrace is false then serialized exception SHOULD NOT have a backtrace.
testJsonserializeexceptionKeys( $expectedKeyType, $exClass, $key)
Lame JSON schema validation.
static provideExceptionClasses()
testUseOutputPage( $expected, $langObj, $wgFullyInitialised, $wgOut)
provideTextUseOutputPage MWException::useOutputPage
testJsonSerializeExceptions( $exception_class)
Verify the exception classes are JSON serializabe.
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
returning false will NOT prevent logging $e