r84827 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84826‎ | r84827 | r84828 >
Date:01:27, 27 March 2011
Author:reedy
Status:ok
Tags:
Comment:
Fixup whitespace from r80445
Modified paths:
  • /trunk/phase3/tests/phpunit/includes/HooksTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/HooksTest.php
@@ -1,130 +1,102 @@
22 <?php
33
4 -
54 class HooksTest extends MediaWikiTestCase {
6 -
7 -
 5+
86 public function testOldStyleHooks() {
9 -
107 $foo = 'Foo';
118 $bar = 'Bar';
12 -
 9+
1310 $i = new NothingClass();
14 -
 11+
1512 global $wgHooks;
16 -
 13+
1714 $wgHooks['MediaWikiHooksTest001'][] = array( $i, 'someNonStatic' );
18 -
 15+
1916 wfRunHooks( 'MediaWikiHooksTest001', array( &$foo, &$bar ) );
20 -
 17+
2118 $this->assertEquals( 'fOO', $foo, 'Standard method' );
2219 $foo = 'Foo';
23 -
24 -
 20+
2521 $wgHooks['MediaWikiHooksTest001'][] = $i;
26 -
 22+
2723 wfRunHooks( 'MediaWikiHooksTest001', array( &$foo, &$bar ) );
28 -
 24+
2925 $this->assertEquals( 'foo', $foo, 'onEventName style' );
3026 $foo = 'Foo';
31 -
32 -
 27+
3328 $wgHooks['MediaWikiHooksTest001'][] = array( $i, 'someNonStaticWithData', 'baz' );
34 -
 29+
3530 wfRunHooks( 'MediaWikiHooksTest001', array( &$foo, &$bar ) );
36 -
 31+
3732 $this->assertEquals( 'baz', $foo, 'Data included' );
3833 $foo = 'Foo';
39 -
40 -
 34+
4135 $wgHooks['MediaWikiHooksTest001'][] = array( $i, 'someStatic' );
42 -
 36+
4337 wfRunHooks( 'MediaWikiHooksTest001', array( &$foo, &$bar ) );
44 -
 38+
4539 $this->assertEquals( 'bah', $foo, 'Standard static method' );
46 - $foo = 'Foo';
47 -
48 -
 40+ //$foo = 'Foo';
 41+
4942 unset( $wgHooks['MediaWikiHooksTest001'] );
50 -
 43+
5144 }
52 -
 45+
5346 public function testNewStyleHooks() {
54 -
5547 $foo = 'Foo';
5648 $bar = 'Bar';
57 -
 49+
5850 $i = new NothingClass();
59 -
60 -
 51+
6152 Hooks::register( 'MediaWikiHooksTest001', array( $i, 'someNonStatic' ) );
62 -
 53+
6354 Hooks::run( 'MediaWikiHooksTest001', array( &$foo, &$bar ) );
64 -
 55+
6556 $this->assertEquals( 'fOO', $foo, 'Standard method' );
6657 $foo = 'Foo';
67 -
68 -
 58+
6959 Hooks::register( 'MediaWikiHooksTest001', $i );
70 -
 60+
7161 Hooks::run( 'MediaWikiHooksTest001', array( &$foo, &$bar ) );
72 -
 62+
7363 $this->assertEquals( 'foo', $foo, 'onEventName style' );
7464 $foo = 'Foo';
75 -
76 -
 65+
7766 Hooks::register( 'MediaWikiHooksTest001', array( $i, 'someNonStaticWithData', 'baz' ) );
78 -
 67+
7968 Hooks::run( 'MediaWikiHooksTest001', array( &$foo, &$bar ) );
80 -
 69+
8170 $this->assertEquals( 'baz', $foo, 'Data included' );
8271 $foo = 'Foo';
83 -
84 -
 72+
8573 Hooks::register( 'MediaWikiHooksTest001', array( $i, 'someStatic' ) );
86 -
 74+
8775 Hooks::run( 'MediaWikiHooksTest001', array( &$foo, &$bar ) );
88 -
 76+
8977 $this->assertEquals( 'bah', $foo, 'Standard static method' );
9078 $foo = 'Foo';
91 -
9279 }
93 -
9480 }
9581
9682 class NothingClass {
97 -
9883 static public function someStatic( &$foo, &$bar ) {
99 -
10084 $foo = 'bah';
101 -
10285 return true;
103 -
10486 }
105 -
 87+
10688 public function someNonStatic( &$foo, &$bar ) {
107 -
10889 $foo = 'fOO';
10990 $bar = 'bAR';
110 -
11191 return true;
112 -
11392 }
114 -
 93+
11594 public function onMediaWikiHooksTest001( &$foo, &$bar ) {
116 -
11795 $foo = 'foo';
118 -
11996 return true;
120 -
12197 }
122 -
 98+
12399 public function someNonStaticWithData( $foo, &$bar ) {
124 -
125100 $bar = $foo;
126 -
127101 return true;
128 -
129102 }
130 -
131103 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r80445Followup to r80435: Forgot the svn addsoxred9316:43, 17 January 2011

Status & tagging log