diff options
author | ArthurHoaro <arthur@hoa.ro> | 2016-02-23 19:21:14 +0100 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2016-02-28 14:17:40 +0100 |
commit | c51fae92dc7d3080def81a2797e0d683b3e6d82a (patch) | |
tree | 394f9419589c1983d9be9834b89c8be2e8ef237c /tests | |
parent | 6c3d6a31f413862941fe514e7167c04fe71ba1a7 (diff) | |
download | Shaarli-c51fae92dc7d3080def81a2797e0d683b3e6d82a.tar.gz Shaarli-c51fae92dc7d3080def81a2797e0d683b3e6d82a.tar.zst Shaarli-c51fae92dc7d3080def81a2797e0d683b3e6d82a.zip |
Allow crossed search between terms and tags
* Partial fix of #449
* Current use case: search term + click on tag.
* LinkFilter now returns all links if no filter is given.
* Unit tests.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/LinkFilterTest.php | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/tests/LinkFilterTest.php b/tests/LinkFilterTest.php index 31fd4cf4..ef1cc10a 100644 --- a/tests/LinkFilterTest.php +++ b/tests/LinkFilterTest.php | |||
@@ -12,6 +12,8 @@ class LinkFilterTest extends PHPUnit_Framework_TestCase | |||
12 | */ | 12 | */ |
13 | protected static $linkFilter; | 13 | protected static $linkFilter; |
14 | 14 | ||
15 | protected static $NB_LINKS_REFDB = 7; | ||
16 | |||
15 | /** | 17 | /** |
16 | * Instanciate linkFilter with ReferenceLinkDB data. | 18 | * Instanciate linkFilter with ReferenceLinkDB data. |
17 | */ | 19 | */ |
@@ -27,7 +29,7 @@ class LinkFilterTest extends PHPUnit_Framework_TestCase | |||
27 | public function testFilter() | 29 | public function testFilter() |
28 | { | 30 | { |
29 | $this->assertEquals( | 31 | $this->assertEquals( |
30 | 7, | 32 | self::$NB_LINKS_REFDB, |
31 | count(self::$linkFilter->filter('', '')) | 33 | count(self::$linkFilter->filter('', '')) |
32 | ); | 34 | ); |
33 | 35 | ||
@@ -36,6 +38,16 @@ class LinkFilterTest extends PHPUnit_Framework_TestCase | |||
36 | 2, | 38 | 2, |
37 | count(self::$linkFilter->filter('', '', false, true)) | 39 | count(self::$linkFilter->filter('', '', false, true)) |
38 | ); | 40 | ); |
41 | |||
42 | $this->assertEquals( | ||
43 | self::$NB_LINKS_REFDB, | ||
44 | count(self::$linkFilter->filter(LinkFilter::$FILTER_TAG, '')) | ||
45 | ); | ||
46 | |||
47 | $this->assertEquals( | ||
48 | self::$NB_LINKS_REFDB, | ||
49 | count(self::$linkFilter->filter(LinkFilter::$FILTER_TEXT, '')) | ||
50 | ); | ||
39 | } | 51 | } |
40 | 52 | ||
41 | /** | 53 | /** |
@@ -341,4 +353,41 @@ class LinkFilterTest extends PHPUnit_Framework_TestCase | |||
341 | count(self::$linkFilter->filter(LinkFilter::$FILTER_TAG, '-free')) | 353 | count(self::$linkFilter->filter(LinkFilter::$FILTER_TAG, '-free')) |
342 | ); | 354 | ); |
343 | } | 355 | } |
356 | |||
357 | /** | ||
358 | * Test crossed search (terms + tags). | ||
359 | */ | ||
360 | public function testFilterCrossedSearch() | ||
361 | { | ||
362 | $terms = '"Free Software " stallman "read this" @website stuff'; | ||
363 | $tags = 'free'; | ||
364 | $this->assertEquals( | ||
365 | 1, | ||
366 | count(self::$linkFilter->filter( | ||
367 | LinkFilter::$FILTER_TAG | LinkFilter::$FILTER_TEXT, | ||
368 | array($tags, $terms) | ||
369 | )) | ||
370 | ); | ||
371 | $this->assertEquals( | ||
372 | 2, | ||
373 | count(self::$linkFilter->filter( | ||
374 | LinkFilter::$FILTER_TAG | LinkFilter::$FILTER_TEXT, | ||
375 | array('', $terms) | ||
376 | )) | ||
377 | ); | ||
378 | $this->assertEquals( | ||
379 | 1, | ||
380 | count(self::$linkFilter->filter( | ||
381 | LinkFilter::$FILTER_TAG | LinkFilter::$FILTER_TEXT, | ||
382 | array($tags, '') | ||
383 | )) | ||
384 | ); | ||
385 | $this->assertEquals( | ||
386 | self::$NB_LINKS_REFDB, | ||
387 | count(self::$linkFilter->filter( | ||
388 | LinkFilter::$FILTER_TAG | LinkFilter::$FILTER_TEXT, | ||
389 | '' | ||
390 | )) | ||
391 | ); | ||
392 | } | ||
344 | } | 393 | } |