* @dataProvider provideTextUseOutputPage
* @covers MWException::useOutputPage
*/
- public function testUseOutputPage( $expected, $wgLang, $wgFullyInitialised, $wgOut ) {
- $this->setMwGlobals( array(
- 'wgLang' => $wgLang,
+ public function testUseOutputPage( $expected, $langObj, $wgFullyInitialised, $wgOut ) {
+ $this->setMwGlobals( [
+ 'wgLang' => $langObj,
'wgFullyInitialised' => $wgFullyInitialised,
'wgOut' => $wgOut,
- ) );
+ ] );
$e = new MWException();
$this->assertEquals( $expected, $e->useOutputPage() );
}
public function provideTextUseOutputPage() {
- return array(
- // expected, wgLang, wgFullyInitialised, wgOut
- array( false, null, null, null ),
- array( false, $this->getMockLanguage(), null, null ),
- array( false, $this->getMockLanguage(), true, null ),
- array( false, null, true, null ),
- array( false, null, null, true ),
- array( true, $this->getMockLanguage(), true, true ),
- );
+ return [
+ // expected, langObj, wgFullyInitialised, wgOut
+ [ false, null, null, null ],
+ [ false, $this->getMockLanguage(), null, null ],
+ [ false, $this->getMockLanguage(), true, null ],
+ [ false, null, true, null ],
+ [ false, null, null, true ],
+ [ true, $this->getMockLanguage(), true, true ],
+ ];
}
private function getMockLanguage() {
* @dataProvider provideUseMessageCache
* @covers MWException::useMessageCache
*/
- public function testUseMessageCache( $expected, $wgLang ) {
- $this->setMwGlobals( array(
- 'wgLang' => $wgLang,
- ) );
+ public function testUseMessageCache( $expected, $langObj ) {
+ $this->setMwGlobals( [
+ 'wgLang' => $langObj,
+ ] );
$e = new MWException();
$this->assertEquals( $expected, $e->useMessageCache() );
}
public function provideUseMessageCache() {
- return array(
- array( false, null ),
- array( true, $this->getMockLanguage() ),
- );
+ return [
+ [ false, null ],
+ [ true, $this->getMockLanguage() ],
+ ];
}
/**
* @covers MWException::runHooks
*/
public function testRunHooks( $wgExceptionHooks, $name, $args, $expectedReturn ) {
- $this->setMwGlobals( array(
+ $this->setMwGlobals( [
'wgExceptionHooks' => $wgExceptionHooks,
- ) );
+ ] );
$e = new MWException();
$this->assertEquals( $expectedReturn, $e->runHooks( $name, $args ) );
}
public static function provideRunHooks() {
- return array(
- array( null, null, null, null ),
- array( array(), 'name', array(), null ),
- array( array( 'name' => false ), 'name', array(), null ),
- array(
- array( 'mockHook' => array( 'MWExceptionTest::mockHook' ) ),
- 'mockHook', array(), 'YAY.[]'
- ),
- array(
- array( 'mockHook' => array( 'MWExceptionTest::mockHook' ) ),
- 'mockHook', array( 'a' ), 'YAY.{"1":"a"}'
- ),
- array(
- array( 'mockHook' => array( 'MWExceptionTest::mockHook' ) ),
- 'mockHook', array( null ), null
- ),
- );
+ return [
+ [ null, null, null, null ],
+ [ [], 'name', [], null ],
+ [ [ 'name' => false ], 'name', [], null ],
+ [
+ [ 'mockHook' => [ 'MWExceptionTest::mockHook' ] ],
+ 'mockHook', [], 'YAY.[]'
+ ],
+ [
+ [ 'mockHook' => [ 'MWExceptionTest::mockHook' ] ],
+ 'mockHook', [ 'a' ], 'YAY.{"1":"a"}'
+ ],
+ [
+ [ 'mockHook' => [ 'MWExceptionTest::mockHook' ] ],
+ 'mockHook', [ null ], null
+ ],
+ ];
}
/**
* @covers MWException::isCommandLine
*/
public function testisCommandLine( $expected, $wgCommandLineMode ) {
- $this->setMwGlobals( array(
+ $this->setMwGlobals( [
'wgCommandLineMode' => $wgCommandLineMode,
- ) );
+ ] );
$e = new MWException();
$this->assertEquals( $expected, $e->isCommandLine() );
}
public static function provideIsCommandLine() {
- return array(
- array( false, null ),
- array( true, true ),
- );
+ return [
+ [ false, null ],
+ [ true, true ],
+ ];
}
/**
}
public static function provideExceptionClasses() {
- return array(
- array( 'Exception' ),
- array( 'MWException' ),
- );
+ return [
+ [ 'Exception' ],
+ [ 'MWException' ],
+ ];
}
/**
public function testJsonserializeexceptionKeys( $expectedKeyType, $exClass, $key ) {
# Make sure we log a backtrace:
- $this->setMwGlobals( array( 'wgLogExceptionBacktrace' => true ) );
+ $this->setMwGlobals( [ 'wgLogExceptionBacktrace' => true ] );
$json = json_decode(
MWExceptionHandler::jsonSerializeException( new $exClass() )
* Returns test cases: exception class, key name, gettype()
*/
public static function provideJsonSerializedKeys() {
- $testCases = array();
- foreach ( array( 'Exception', 'MWException' ) as $exClass ) {
- $exTests = array(
- array( 'string', $exClass, 'id' ),
- array( 'string', $exClass, 'file' ),
- array( 'integer', $exClass, 'line' ),
- array( 'string', $exClass, 'message' ),
- array( 'null', $exClass, 'url' ),
+ $testCases = [];
+ foreach ( [ 'Exception', 'MWException' ] as $exClass ) {
+ $exTests = [
+ [ 'string', $exClass, 'id' ],
+ [ 'string', $exClass, 'file' ],
+ [ 'integer', $exClass, 'line' ],
+ [ 'string', $exClass, 'message' ],
+ [ 'null', $exClass, 'url' ],
# Backtrace only enabled with wgLogExceptionBacktrace = true
- array( 'array', $exClass, 'backtrace' ),
- );
+ [ 'array', $exClass, 'backtrace' ],
+ ];
$testCases = array_merge( $testCases, $exTests );
}
return $testCases;
* @covers MWExceptionHandler::jsonSerializeException
*/
public function testJsonserializeexceptionBacktracingEnabled() {
- $this->setMwGlobals( array( 'wgLogExceptionBacktrace' => true ) );
+ $this->setMwGlobals( [ 'wgLogExceptionBacktrace' => true ] );
$json = json_decode(
MWExceptionHandler::jsonSerializeException( new Exception() )
);
* @covers MWExceptionHandler::jsonSerializeException
*/
public function testJsonserializeexceptionBacktracingDisabled() {
- $this->setMwGlobals( array( 'wgLogExceptionBacktrace' => false ) );
+ $this->setMwGlobals( [ 'wgLogExceptionBacktrace' => false ] );
$json = json_decode(
MWExceptionHandler::jsonSerializeException( new Exception() )
);