8 Hooks::clear(
'MediaWikiHooksTest001' );
9 unset(
$wgHooks[
'MediaWikiHooksTest001'] );
18 [ $i,
'someNonStatic' ],
22 [
'Object and no method', [ $i ],
'changed-onevent',
'original' ],
24 'Object and method with data',
25 [ $i,
'someNonStaticWithData',
'data' ],
29 [
'Object and static method', [ $i,
'someStatic' ],
'changed-static',
'original' ],
31 'Class::method static call',
32 [
'NothingClass::someStatic' ],
37 'Class::method static call as array',
38 [ [
'NothingClass::someStatic' ] ],
42 [
'Global function', [
'NothingFunction' ],
'changed-func',
'original' ],
43 [
'Global function with data', [
'NothingFunctionData',
'data' ],
'data',
'original' ],
44 [
'Closure', [
function ( &$foo, $bar ) {
45 $foo =
'changed-closure';
48 } ],
'changed-closure',
'original' ],
49 [
'Closure with data', [
function ( $data, &$foo, $bar ) {
53 },
'data' ],
'data',
'original' ]
64 $foo = $bar =
'original';
66 Hooks::register(
'MediaWikiHooksTest001', $hook );
67 Hooks::run(
'MediaWikiHooksTest001', [ &$foo, &$bar ] );
69 $this->assertSame( $expectedFoo, $foo, $msg );
70 $this->assertSame( $expectedBar, $bar, $msg );
81 Hooks::getHandlers(
'MediaWikiHooksTest001' ),
88 $wgHooks[
'MediaWikiHooksTest001'][] = $a;
92 Hooks::getHandlers(
'MediaWikiHooksTest001' ),
93 'Hook registered by $wgHooks'
96 Hooks::register(
'MediaWikiHooksTest001', $b );
99 Hooks::getHandlers(
'MediaWikiHooksTest001' ),
100 'Hooks::getHandlers() should return hooks registered via wgHooks as well as Hooks::register'
103 Hooks::clear(
'MediaWikiHooksTest001' );
104 unset(
$wgHooks[
'MediaWikiHooksTest001'] );
106 Hooks::register(
'MediaWikiHooksTest001', $b );
109 Hooks::getHandlers(
'MediaWikiHooksTest001' ),
110 'Hook registered by Hook::register'
126 $wgHooks[
'MediaWikiHooksTest001'][] = $a;
128 Hooks::isRegistered(
'MediaWikiHooksTest001' ),
129 'Hook registered via $wgHooks should be noticed by Hooks::isRegistered'
132 Hooks::register(
'MediaWikiHooksTest001', $b );
135 count( Hooks::getHandlers(
'MediaWikiHooksTest001' ) ),
136 'Hooks::getHandlers() should return hooks registered via wgHooks as well as Hooks::register'
142 Hooks::run(
'MediaWikiHooksTest001', [ &$foo, &$bar ] );
146 'Hooks::run() should run hooks registered via wgHooks as well as Hooks::register'
151 'Hooks::run() should run hooks registered via wgHooks as well as Hooks::register'
161 Hooks::register(
'MediaWikiHooksTest001',
'ThisFunctionDoesntExist' );
162 Hooks::run(
'MediaWikiHooksTest001', [] );
170 Hooks::register(
'MediaWikiHooksTest001',
function ( &$foo ) {
173 Hooks::register(
'MediaWikiHooksTest001',
function ( &$foo ) {
179 Hooks::run(
'MediaWikiHooksTest001', [ &$foo ] );
180 $this->assertSame(
'original', $foo,
'Hooks abort after a false return.' );
187 Hooks::register(
'MediaWikiHooksTest001',
function ( &$foo ) {
190 Hooks::register(
'MediaWikiHooksTest001',
function ( &$foo ) {
196 Hooks::run(
'MediaWikiHooksTest001', [ &$foo ] );
197 $this->assertSame(
'test', $foo,
'Hooks continue after a null return.' );
204 Hooks::register(
'MediaWikiHooksTest001',
false );
205 Hooks::register(
'MediaWikiHooksTest001',
function ( &$foo ) {
211 Hooks::run(
'MediaWikiHooksTest001', [ &$foo ] );
212 $this->assertSame(
'test', $foo,
'Hooks that are falsey are skipped.' );
220 Hooks::register(
'MediaWikiHooksTest001', 12345 );
221 Hooks::run(
'MediaWikiHooksTest001' );
229 Hooks::register(
'MediaWikiHooksTest001',
'NothingClass::someStatic' );
230 Hooks::run(
'MediaWikiHooksTest001', [],
'1.31' );
239 Hooks::register(
'MediaWikiHooksTest001',
function ( &$list ) {
243 Hooks::register(
'MediaWikiHooksTest001',
function ( &$list ) {
247 Hooks::register(
'MediaWikiHooksTest001',
function ( &$list ) {
252 Hooks::runWithoutAbort(
'MediaWikiHooksTest001', [ &$list ] );
253 $this->assertSame( [ 1, 2, 3 ], $list,
'All hooks ran.' );
261 Hooks::register(
'MediaWikiHooksTest001',
function ( &$foo ) {
264 Hooks::register(
'MediaWikiHooksTest001',
function ( &$foo ) {
270 $this->setExpectedException(
271 UnexpectedValueException::class,
272 'Invalid return from hook-MediaWikiHooksTest001-closure for ' .
273 'unabortable MediaWikiHooksTest001'
275 Hooks::runWithoutAbort(
'MediaWikiHooksTest001', [ &$foo ] );
283 Hooks::register(
'MediaWikiHooksTest001',
function () {
286 Hooks::run(
'MediaWikiHooksTest001', [] );
291 $foo =
'changed-func';
306 $foo =
'changed-static';
313 $foo =
'changed-nonstatic';
314 $bar =
'changed-nonstatic';
321 $foo =
'changed-onevent';
NothingFunction(&$foo, &$bar)
NothingFunctionData( $data, &$foo, &$bar)
testFatalError()
FatalError Hooks::run.
testUncallableFunction()
MWException Hooks::run Hooks::callHook.
testCallHook_Deprecated()
Hooks::callHook PHPUnit_Framework_Error_Deprecated.
testFalseReturn()
Hooks::run Hooks::callHook.
testNewStyleHookInteraction()
Hooks::isRegistered Hooks::register Hooks::run Hooks::callHook.
testNewStyleHooks( $msg, $hook, $expectedFoo, $expectedBar)
provideHooks Hooks::register Hooks::run Hooks::callHook
testRunWithoutAbortWarning()
Hooks::runWithoutAbort Hooks::callHook.
testCallHook_UnknownDatatype()
Hooks::callHook MWException.
testNullReturn()
Hooks::run.
testGetHandlers()
Hooks::getHandlers.
testRunWithoutAbort()
Hooks::runWithoutAbort Hooks::callHook.
testCallHook_FalseHook()
Hooks::callHook.
static someStatic(&$foo, &$bar)
someNonStaticWithData( $data, &$foo, &$bar)
someNonStatic(&$foo, &$bar)
onMediaWikiHooksTest001(&$foo, &$bar)
$wgHooks['ArticleShow'][]