aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorArthur <arthur@hoa.ro>2016-02-28 14:26:46 +0100
committerArthur <arthur@hoa.ro>2016-02-28 14:26:46 +0100
commitc6744a9e89b62ba94563c43ab33f964ec0b11a17 (patch)
tree30e6274a05636d06b10a5749d4786d5d95ccedf0 /tests
parent10269bc8c9dfe87eb213c09a44308ce64ae0c12d (diff)
parentc51fae92dc7d3080def81a2797e0d683b3e6d82a (diff)
downloadShaarli-c6744a9e89b62ba94563c43ab33f964ec0b11a17.tar.gz
Shaarli-c6744a9e89b62ba94563c43ab33f964ec0b11a17.tar.zst
Shaarli-c6744a9e89b62ba94563c43ab33f964ec0b11a17.zip
Merge pull request #496 from ArthurHoaro/cross-search
Allow crossed search between terms and tags
Diffstat (limited to 'tests')
-rw-r--r--tests/LinkFilterTest.php51
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}