8 Hooks::clear(
'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' ],
53 },
'data' ],
'data',
'original' ]
64 $foo = $bar =
'original';
66 Hooks::register(
'MediaWikiHooksTest001', $hook );
67 Hooks::run(
'MediaWikiHooksTest001', [ &$foo, &$bar ] );
81 Hooks::getHandlers(
'MediaWikiHooksTest001' ),
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' );
106 Hooks::register(
'MediaWikiHooksTest001', $b );
109 Hooks::getHandlers(
'MediaWikiHooksTest001' ),
110 'Hook registered by Hook::register'
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 ) {
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';
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
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'][]
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)