@@ -296,62 +296,74 @@ public function test_ajax_postfix()
296
296
297
297
$ INPUT ->set ('search ' , 'oku ' );
298
298
$ this ->assertEquals ([['label ' => 'dokuwiki (wiki) ' , 'value ' => 'wiki:dokuwiki ' ]], $ page ->handleAjax ());
299
+
300
+ $ page = new Page (
301
+ [
302
+ 'autocomplete ' => [
303
+ 'mininput ' => 2 ,
304
+ 'maxresult ' => 5 ,
305
+ 'namespace ' => 'wiki ' ,
306
+ 'postfix ' => 'iki ' ,
307
+ ],
308
+ ]
309
+ );
310
+
311
+ $ INPUT ->set ('search ' , 'oku ' );
312
+ $ this ->assertEquals ([['label ' => 'dokuwiki (wiki) ' , 'value ' => 'wiki:dokuwiki ' ]], $ page ->handleAjax ());
299
313
}
300
314
301
315
/**
302
- * Test simple namespace matching in autocompletion
316
+ * Test simple filter matching in autocompletion
303
317
*
304
318
* @return void
305
319
*/
306
- public function test_namespace_matching_simple ()
320
+ public function test_filter_matching_simple ()
307
321
{
308
322
$ page = new Page ();
309
323
310
- $ this ->assertTrue ($ page ->nsMatch ('foo:start ' , 'foo ' ));
311
- $ this ->assertFalse ($ page ->nsMatch ('start#foo ' , 'foo ' ));
312
- $ this ->assertFalse ($ page ->nsMatch ('ns:foo ' , ':foo ' ));
313
- $ this ->assertTrue ($ page ->nsMatch ('ns:foo:start ' , 'foo ' ));
314
- $ this ->assertTrue ($ page ->nsMatch ('ns:foo:start#headline ' , 'foo ' ));
315
- $ this ->assertTrue ($ page ->nsMatch ('foo-bar:start ' , 'foo-bar ' ));
316
- $ this ->assertTrue ($ page ->nsMatch ('foo-bar:start-with_special.chars ' , 'foo-bar ' ));
317
- $ this ->assertTrue ($ page ->nsMatch ('foo.bar:start ' , 'foo.bar ' ));
318
- $ this ->assertFalse ($ page ->nsMatch ('ns:foo.bar ' , 'foo.bar ' ));
319
- $ this ->assertTrue ($ page ->nsMatch ('ns:foo.bar:start ' , 'foo.bar ' ));
320
- $ this ->assertFalse ($ page ->nsMatch ('ns:foo_bar:start ' , ':foo_bar ' ));
321
- $ this ->assertTrue ($ page ->nsMatch ('8bar:start ' , '8bar ' ));
322
- $ this ->assertTrue ($ page ->nsMatch ('ns:8bar:start ' , '8bar ' ));
323
- $ this ->assertFalse ($ page ->nsMatch ('ns:98bar:start ' , '8bar ' ));
324
+ $ this ->assertTrue ($ page ->filterMatch ('foo:start ' , 'foo ' ));
325
+ $ this ->assertTrue ($ page ->filterMatch ('start#foo ' , 'foo ' ));
326
+ $ this ->assertFalse ($ page ->filterMatch ('ns:foo ' , ':foo ' ));
327
+ $ this ->assertTrue ($ page ->filterMatch ('foo-bar:start ' , 'foo-bar ' ));
328
+ $ this ->assertTrue ($ page ->filterMatch ('foo-bar:start-with_special.chars ' , 'foo-bar ' ));
329
+ $ this ->assertTrue ($ page ->filterMatch ('foo.bar:start ' , 'foo.bar ' ));
330
+ $ this ->assertTrue ($ page ->filterMatch ('ns:foo.bar ' , 'foo.bar ' ));
331
+ $ this ->assertTrue ($ page ->filterMatch ('ns:foo.bar:start ' , 'foo.bar ' ));
332
+ $ this ->assertFalse ($ page ->filterMatch ('ns:foo_bar:start ' , ':foo_bar ' ));
333
+ $ this ->assertTrue ($ page ->filterMatch ('8bar:start ' , '8bar ' ));
334
+ $ this ->assertTrue ($ page ->filterMatch ('ns:8bar:start ' , '8bar ' ));
335
+ $ this ->assertTrue ($ page ->filterMatch ('ns:98bar:start ' , '8bar ' ));
324
336
}
325
337
326
338
/**
327
- * Test regex namespace matching in autocompletion
339
+ * Test pattern matching in autocompletion
328
340
*
329
341
* @return void
330
342
*/
331
- public function test_namespace_matching_regex ()
343
+ public function test_filter_matching_regex ()
332
344
{
333
345
$ page = new Page ();
334
346
335
- $ namespace = '/ (foo:|^:foo:|(?::|^)bar:|foo:bar|foo-bar:|^:foo_bar:|foo\.bar:|(?::|^)8bar:)/ ' ;
336
-
337
- $ this ->assertTrue ($ page ->nsMatch ('foo:start ' , $ namespace ));
338
- $ this ->assertFalse ($ page ->nsMatch ('start#foo ' , $ namespace ));
339
- $ this ->assertFalse ($ page ->nsMatch ('ns:foo ' , $ namespace ));
340
- $ this ->assertTrue ($ page ->nsMatch ('bar:foo ' , $ namespace ));
341
- $ this ->assertTrue ($ page ->nsMatch ('ns:foo:start ' , $ namespace ));
342
- $ this ->assertTrue ($ page ->nsMatch ('ns:foo:start#headline ' , $ namespace ));
343
- $ this ->assertTrue ($ page ->nsMatch ('foo-bar:start ' , $ namespace ));
344
- $ this ->assertTrue ($ page ->nsMatch ('foo-bar:start-with_special.chars ' , $ namespace ));
345
- $ this ->assertTrue ($ page ->nsMatch ('foo.bar:start ' , $ namespace ));
346
- $ this ->assertFalse ($ page ->nsMatch ('ns:foo.bar ' , $ namespace ));
347
- $ this ->assertTrue ($ page ->nsMatch ('ns:foo.bar:start ' , $ namespace ));
348
- $ this ->assertFalse ($ page ->nsMatch ('ns:foo_bar:start ' , $ namespace ));
349
- $ this ->assertTrue ($ page ->nsMatch ('8bar:start ' , $ namespace ));
350
- $ this ->assertTrue ($ page ->nsMatch ('ns:8bar:start ' , $ namespace ));
351
- $ this ->assertFalse ($ page ->nsMatch ('ns:98bar:start ' , $ namespace ));
352
-
353
- $ namespace = '/ ^:systems:[^:]+:components:([^:]+:){1,2}$/ ' ;
354
- $ this ->assertTrue ($ page ->nsMatch ('systems:system1:components:sub1:sub2:start ' , $ namespace ));
355
- $ this ->assertFalse ($ page ->nsMatch ('systems:system1:components:sub1:sub2:sub3:start ' , $ namespace ));
347
+ $ filter = '(foo:|^:foo:|(?::|^)bar:|foo:bar|foo-bar:|^:foo_bar:|foo\.bar:|(?::|^)8bar:) ' ;
348
+
349
+ $ this ->assertTrue ($ page ->filterMatch ('foo:start ' , $ filter ));
350
+ $ this ->assertFalse ($ page ->filterMatch ('start#foo ' , $ filter ));
351
+ $ this ->assertFalse ($ page ->filterMatch ('ns:foo ' , $ filter ));
352
+ $ this ->assertTrue ($ page ->filterMatch ('bar:foo ' , $ filter ));
353
+ $ this ->assertTrue ($ page ->filterMatch ('ns:foo:start ' , $ filter ));
354
+ $ this ->assertTrue ($ page ->filterMatch ('ns:foo:start#headline ' , $ filter ));
355
+ $ this ->assertTrue ($ page ->filterMatch ('foo-bar:start ' , $ filter ));
356
+ $ this ->assertTrue ($ page ->filterMatch ('foo-bar:start-with_special.chars ' , $ filter ));
357
+ $ this ->assertTrue ($ page ->filterMatch ('foo.bar:start ' , $ filter ));
358
+ $ this ->assertFalse ($ page ->filterMatch ('ns:foo.bar ' , $ filter ));
359
+ $ this ->assertTrue ($ page ->filterMatch ('ns:foo.bar:start ' , $ filter ));
360
+ $ this ->assertFalse ($ page ->filterMatch ('ns:foo_bar:start ' , $ filter ));
361
+ $ this ->assertTrue ($ page ->filterMatch ('8bar:start ' , $ filter ));
362
+ $ this ->assertTrue ($ page ->filterMatch ('ns:8bar:start ' , $ filter ));
363
+ $ this ->assertFalse ($ page ->filterMatch ('ns:98bar:start ' , $ filter ));
364
+
365
+ $ filter = '^:systems:[^:]+:components:([^:]+:){1,2}[^:]+$ ' ;
366
+ $ this ->assertTrue ($ page ->filterMatch ('systems:system1:components:sub1:sub2:start ' , $ filter ));
367
+ $ this ->assertFalse ($ page ->filterMatch ('systems:system1:components:sub1:sub2:sub3:start ' , $ filter ));
356
368
}
357
369
}
0 commit comments