public static function provideHooks() {
$i = new NothingClass();
+
return array(
array( 'Object and method', array( $i, 'someNonStatic' ), 'changed-nonstatic', 'changed-nonstatic' ),
array( 'Object and no method', array( $i ), 'changed-onevent', 'original' ),
array( 'Class::method static call', array( 'NothingClass::someStatic' ), 'changed-static', 'original' ),
array( 'Global function', array( 'NothingFunction' ), 'changed-func', 'original' ),
array( 'Global function with data', array( 'NothingFunctionData', 'data' ), 'data', 'original' ),
- array( 'Closure', array( function( &$foo, $bar ) {
- $foo = 'changed-closure';
- return true;
- } ), 'changed-closure', 'original' ),
- array( 'Closure with data', array( function( $data, &$foo, $bar ) {
- $foo = $data;
- return true;
- }, 'data' ), 'data', 'original' )
+ array( 'Closure', array( function ( &$foo, $bar ) {
+ $foo = 'changed-closure';
+
+ return true;
+ } ), 'changed-closure', 'original' ),
+ array( 'Closure with data', array( function ( $data, &$foo, $bar ) {
+ $foo = $data;
+
+ return true;
+ }, 'data' ), 'data', 'original' )
);
}
}
public function testFalseReturn() {
- Hooks::register( 'MediaWikiHooksTest001', function( &$foo ) { return false; } );
- Hooks::register( 'MediaWikiHooksTest001', function( &$foo ) { $foo = 'test'; return true; } );
+ Hooks::register( 'MediaWikiHooksTest001', function ( &$foo ) {
+ return false;
+ } );
+ Hooks::register( 'MediaWikiHooksTest001', function ( &$foo ) {
+ $foo = 'test';
+
+ return true;
+ } );
$foo = 'original';
Hooks::run( 'MediaWikiHooksTest001', array( &$foo ) );
$this->assertSame( 'original', $foo, 'Hooks continued processing after a false return.' );
* @expectedException FatalError
*/
public function testFatalError() {
- Hooks::register( 'MediaWikiHooksTest001', function() { return 'test'; } );
+ Hooks::register( 'MediaWikiHooksTest001', function () {
+ return 'test';
+ } );
Hooks::run( 'MediaWikiHooksTest001', array() );
}
}
function NothingFunction( &$foo, &$bar ) {
$foo = 'changed-func';
+
return true;
}
function NothingFunctionData( $data, &$foo, &$bar ) {
$foo = $data;
+
return true;
}
public static function someStatic( &$foo, &$bar ) {
$foo = 'changed-static';
+
return true;
}
$this->calls++;
$foo = 'changed-nonstatic';
$bar = 'changed-nonstatic';
+
return true;
}
public function onMediaWikiHooksTest001( &$foo, &$bar ) {
$this->calls++;
$foo = 'changed-onevent';
+
return true;
}
public function someNonStaticWithData( $data, &$foo, &$bar ) {
$this->calls++;
$foo = $data;
+
return true;
}
}