1<?php 2 3/** 4 * 5 * 6 * @author Michael Große <grosse@cosmocode.de> 7 * 8 * @group plugin_top 9 * @group plugins 10 */ 11 12class test_plugin_top_removeStartpages extends DokuWikiTest { 13 protected $pluginsEnabled = array('top', 'sqlite','translation'); 14 15 function test_removeStartpages_noTranslation() { 16 $helper = plugin_load('helper', 'top'); 17 $list = array( 18 array( 19 'value' => 252, 20 'page' => 'start', 21 ), 22 23 array( 24 'value' => 106, 25 'page' => 'namespace12:start', 26 ), 27 28 array( 29 'value' => 95, 30 'page' => 'snippets:test1', 31 ), 32 33 array( 34 'value' => 74, 35 'page' => 'statistiken:start', 36 ), 37 38 array( 39 'value' => 72, 40 'page' => 'statistiken:top', 41 ), 42 43 array( 44 'value' => 62, 45 'page' => 'sidebar', 46 ), 47 48 array( 49 'value' => 49, 50 'page' => 'snippets:start', 51 ), 52 53 array( 54 'value' => 40, 55 'page' => 'unittests', 56 ), 57 58 array( 59 'value' => 35, 60 'page' => 'pluginsurvey2014:start', 61 ), 62 63 array( 64 'value' => 31, 65 'page' => 'snippets:foo:start', 66 ), 67 68 array( 69 'value' => 27, 70 'page' => 'plugins:navi', 71 ), 72 73 array( 74 'value' => 27, 75 'page' => 'snippets:foo:test1', 76 ), 77 78 array( 79 'value' => 26, 80 'page' => 'snippets', 81 ), 82 83 array( 84 'value' => 23, 85 'page' => 'imagemap', 86 ), 87 88 array( 89 'value' => 23, 90 'page' => 'pluginsurvey2014:codestyle', 91 ), 92 93 array( 94 'value' => 23, 95 'page' => 'snippets:test3', 96 ), 97 98 array( 99 'value' => 22, 100 'page' => 'tabbox', 101 ), 102 103 array( 104 'value' => 18, 105 'page' => 'snippets:test2', 106 ), 107 108 array( 109 'value' => 17, 110 'page' => 'user:michaelsuper', 111 ), 112 113 array( 114 'value' => 16, 115 'page' => 'calenders', 116 ), 117 118 ); 119 $actual_list = $helper->removeStartPages($list); 120 array_shift($list); 121 $expected_list = $list; 122 $this->assertSame($expected_list,$actual_list); 123 } 124 125 function test_removeStartpages_Translation() { 126 global $conf; 127 $conf['plugin']['translation']['translations'] = 'de en'; 128 $helper = plugin_load('helper', 'top'); 129 $list = array( 130 array( 131 'value' => 252, 132 'page' => 'start', 133 ), 134 135 array( 136 'value' => 106, 137 'page' => 'namespace12:start', 138 ), 139 140 array( 141 'value' => 95, 142 'page' => 'snippets:test1', 143 ), 144 145 array( 146 'value' => 74, 147 'page' => 'statistiken:start', 148 ), 149 150 array( 151 'value' => 72, 152 'page' => 'statistiken:top', 153 ), 154 155 array( 156 'value' => 62, 157 'page' => 'sidebar', 158 ), 159 160 array( 161 'value' => 49, 162 'page' => 'snippets:start', 163 ), 164 165 array( 166 'value' => 40, 167 'page' => 'de:start', 168 ), 169 170 array( 171 'value' => 35, 172 'page' => 'pluginsurvey2014:start', 173 ), 174 175 array( 176 'value' => 31, 177 'page' => 'snippets:foo:start', 178 ), 179 180 array( 181 'value' => 27, 182 'page' => 'plugins:navi', 183 ), 184 185 array( 186 'value' => 27, 187 'page' => 'snippets:foo:test1', 188 ), 189 190 array( 191 'value' => 26, 192 'page' => 'en:start', 193 ), 194 195 array( 196 'value' => 23, 197 'page' => 'imagemap', 198 ), 199 200 array( 201 'value' => 23, 202 'page' => 'pluginsurvey2014:codestyle', 203 ), 204 205 array( 206 'value' => 23, 207 'page' => 'snippets:test3', 208 ), 209 210 array( 211 'value' => 22, 212 'page' => 'tabbox', 213 ), 214 215 array( 216 'value' => 18, 217 'page' => 'snippets:test2', 218 ), 219 220 array( 221 'value' => 17, 222 'page' => 'user:michaelsuper', 223 ), 224 225 array( 226 'value' => 16, 227 'page' => 'calenders', 228 ), 229 230 ); 231 $actual_list = $helper->removeStartPages($list); 232 $expected_list = array( 233 array( 234 'value' => 106, 235 'page' => 'namespace12:start', 236 ), 237 238 array( 239 'value' => 95, 240 'page' => 'snippets:test1', 241 ), 242 243 array( 244 'value' => 74, 245 'page' => 'statistiken:start', 246 ), 247 248 array( 249 'value' => 72, 250 'page' => 'statistiken:top', 251 ), 252 253 array( 254 'value' => 62, 255 'page' => 'sidebar', 256 ), 257 258 array( 259 'value' => 49, 260 'page' => 'snippets:start', 261 ), 262 263 array( 264 'value' => 35, 265 'page' => 'pluginsurvey2014:start', 266 ), 267 268 array( 269 'value' => 31, 270 'page' => 'snippets:foo:start', 271 ), 272 273 array( 274 'value' => 27, 275 'page' => 'plugins:navi', 276 ), 277 278 array( 279 'value' => 27, 280 'page' => 'snippets:foo:test1', 281 ), 282 283 array( 284 'value' => 23, 285 'page' => 'imagemap', 286 ), 287 288 array( 289 'value' => 23, 290 'page' => 'pluginsurvey2014:codestyle', 291 ), 292 293 array( 294 'value' => 23, 295 'page' => 'snippets:test3', 296 ), 297 298 array( 299 'value' => 22, 300 'page' => 'tabbox', 301 ), 302 303 array( 304 'value' => 18, 305 'page' => 'snippets:test2', 306 ), 307 308 array( 309 'value' => 17, 310 'page' => 'user:michaelsuper', 311 ), 312 313 array( 314 'value' => 16, 315 'page' => 'calenders', 316 ), 317 318 ); 319 $this->assertSame($expected_list,$actual_list); 320 } 321 322 323} 324