Index: trunk/phase3/maintenance/tests/phpunit/includes/api/ApiSetup.php |
— | — | @@ -6,11 +6,11 @@ |
7 | 7 | protected static $user; |
8 | 8 | protected static $apiUrl; |
9 | 9 | |
10 | | - function setup() { |
| 10 | + function setUp() { |
11 | 11 | global $wgServer, $wgContLang, $wgAuth, $wgScriptPath, |
12 | 12 | $wgScriptExtension, $wgMemc, $wgRequest; |
13 | 13 | |
14 | | - self::$apiUrl = $wgServer . $wgScriptPath . "/api" . $wgScriptExtension; |
| 14 | + self::$apiUrl = $wgServer . wfScript( 'api' ); |
15 | 15 | |
16 | 16 | $wgMemc = new FakeMemCachedClient; |
17 | 17 | $wgContLang = Language::factory( 'en' ); |
— | — | @@ -36,4 +36,9 @@ |
37 | 37 | |
38 | 38 | $GLOBALS['wgUser'] = self::$user; |
39 | 39 | } |
| 40 | + |
| 41 | + function tearDown() { |
| 42 | + global $wgMemc; |
| 43 | + $wgMemc = null; |
| 44 | + } |
40 | 45 | } |
Index: trunk/phase3/maintenance/tests/phpunit/includes/api/ApiWatchTest.php |
— | — | @@ -5,21 +5,9 @@ |
6 | 6 | class ApiWatchTest extends ApiTestSetup { |
7 | 7 | |
8 | 8 | function setUp() { |
9 | | - ini_set( 'log_errors', 1 ); |
10 | | - ini_set( 'error_reporting', 1 ); |
11 | | - ini_set( 'display_errors', 1 ); |
12 | | - |
13 | | - global $wgMemc; |
14 | | - $wgMemc = new FakeMemCachedClient; |
| 9 | + parent::setUp(); |
15 | 10 | } |
16 | 11 | |
17 | | - function tearDown() { |
18 | | - global $wgMemc; |
19 | | - |
20 | | - $wgMemc = null; |
21 | | - } |
22 | | - |
23 | | - |
24 | 12 | function doApiRequest( $params, $data = null ) { |
25 | 13 | $_SESSION = isset( $data[2] ) ? $data[2] : array(); |
26 | 14 | |
— | — | @@ -38,7 +26,7 @@ |
39 | 27 | $data = $this->doApiRequest( array( |
40 | 28 | 'action' => 'login', |
41 | 29 | 'lgname' => self::$userName, |
42 | | - 'lgpassword' => self::$passWord ), $data ); |
| 30 | + 'lgpassword' => self::$passWord ) ); |
43 | 31 | |
44 | 32 | $this->assertArrayHasKey( "login", $data[0] ); |
45 | 33 | $this->assertArrayHasKey( "result", $data[0]['login'] ); |
— | — | @@ -65,11 +53,12 @@ |
66 | 54 | 'action' => 'query', |
67 | 55 | 'titles' => 'Main Page', |
68 | 56 | 'intoken' => 'edit|delete|protect|move|block|unblock', |
69 | | - 'prop' => 'info' ), $data ); |
| 57 | + 'prop' => 'info' ) ); |
70 | 58 | |
71 | 59 | $this->assertArrayHasKey( 'query', $data[0] ); |
72 | 60 | $this->assertArrayHasKey( 'pages', $data[0]['query'] ); |
73 | | - $key = array_pop( array_keys( $data[0]['query']['pages'] ) ); |
| 61 | + $keys = array_keys( $data[0]['query']['pages'] ); |
| 62 | + $key = array_pop( $keys ); |
74 | 63 | |
75 | 64 | $this->assertArrayHasKey( $key, $data[0]['query']['pages'] ); |
76 | 65 | $this->assertArrayHasKey( 'edittoken', $data[0]['query']['pages'][$key] ); |
— | — | @@ -86,7 +75,8 @@ |
87 | 76 | * @depends testGetToken |
88 | 77 | */ |
89 | 78 | function testWatchEdit( $data ) { |
90 | | - $key = array_pop( array_keys( $data[0]['query']['pages'] ) ); |
| 79 | + $keys = array_keys( $data[0]['query']['pages'] ); |
| 80 | + $key = array_pop( $keys ); |
91 | 81 | $pageinfo = $data[0]['query']['pages'][$key]; |
92 | 82 | |
93 | 83 | $data = $this->doApiRequest( array( |
— | — | @@ -135,7 +125,8 @@ |
136 | 126 | * @depends testGetToken |
137 | 127 | */ |
138 | 128 | function testWatchProtect( $data ) { |
139 | | - $key = array_pop( array_keys( $data[0]['query']['pages'] ) ); |
| 129 | + $keys = array_keys( $data[0]['query']['pages'] ); |
| 130 | + $key = array_pop( $keys ); |
140 | 131 | $pageinfo = $data[0]['query']['pages'][$key]; |
141 | 132 | |
142 | 133 | $data = $this->doApiRequest( array( |
— | — | @@ -163,7 +154,8 @@ |
164 | 155 | |
165 | 156 | $this->assertArrayHasKey( 'query', $data[0] ); |
166 | 157 | $this->assertArrayHasKey( 'pages', $data[0]['query'] ); |
167 | | - $key = array_pop( array_keys( $data[0]['query']['pages'] ) ); |
| 158 | + $keys = array_keys( $data[0]['query']['pages'] ); |
| 159 | + $key = array_pop( $keys ); |
168 | 160 | |
169 | 161 | $this->assertArrayHasKey( 'pageid', $data[0]['query']['pages'][$key] ); |
170 | 162 | $this->assertArrayHasKey( 'revisions', $data[0]['query']['pages'][$key] ); |
— | — | @@ -177,7 +169,8 @@ |
178 | 170 | * @depends testGetRollbackToken |
179 | 171 | */ |
180 | 172 | function testWatchRollback( $data ) { |
181 | | - $key = array_pop( array_keys( $data[0]['query']['pages'] ) ); |
| 173 | + $keys = array_keys( $data[0]['query']['pages'] ); |
| 174 | + $key = array_pop( $keys ); |
182 | 175 | $pageinfo = $data[0]['query']['pages'][$key]['revisions'][0]; |
183 | 176 | |
184 | 177 | $data = $this->doApiRequest( array( |
— | — | @@ -195,7 +188,8 @@ |
196 | 189 | * @depends testGetToken |
197 | 190 | */ |
198 | 191 | function testWatchDelete( $data ) { |
199 | | - $key = array_pop( array_keys( $data[0]['query']['pages'] ) ); |
| 192 | + $keys = array_keys( $data[0]['query']['pages'] ); |
| 193 | + $key = array_pop( $keys ); |
200 | 194 | $pageinfo = $data[0]['query']['pages'][$key]; |
201 | 195 | |
202 | 196 | $data = $this->doApiRequest( array( |