31 $this->assertEquals( $expected,
$e->useOutputPage() );
37 [
false,
null,
null, null ],
40 [
false,
null,
true, null ],
41 [
false,
null,
null,
true ],
47 return $this->getMockBuilder( Language::class )
48 ->disableOriginalConstructor()
61 $this->assertEquals( $expected,
$e->useMessageCache() );
76 $this->assertTrue(
$e->isLoggable() );
88 $this->assertEquals( $expected,
$e->isCommandLine() );
105 $json = MWExceptionHandler::jsonSerializeException(
106 new $exception_class()
108 $this->assertNotEquals(
false, $json,
109 "The $exception_class exception should be JSON serializable, got false." );
114 [ Exception::class ],
115 [ MWException::class ],
130 # Make sure we log a backtrace:
131 $this->
setMwGlobals( [
'wgLogExceptionBacktrace' =>
true ] );
134 MWExceptionHandler::jsonSerializeException(
new $exClass() )
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)."
150 foreach ( [ Exception::class, MWException::class ] as $exClass ) {
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 ] );
174 MWExceptionHandler::jsonSerializeException(
new Exception() )
176 $this->assertObjectHasAttribute(
'backtrace', $json );
186 $this->
setMwGlobals( [
'wgLogExceptionBacktrace' =>
false ] );
188 MWExceptionHandler::jsonSerializeException(
new Exception() )
190 $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 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