From 7d86f40bdb2135655b5b4fe8cbcc1ac102114f86 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sat, 1 Apr 2017 12:17:37 +0200 Subject: Empty tag search will look for not tagged links Fixes #784 From now, searching for tags with an empty value will return only not tagged links, with the search bar showing `x results [not tagged]`. Note that using the api, the searchtags request parameter must be set to `false` to get the same result. - [ ] Update API doc --- tests/LinkFilterTest.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'tests/LinkFilterTest.php') diff --git a/tests/LinkFilterTest.php b/tests/LinkFilterTest.php index 37d5ca30..74162358 100644 --- a/tests/LinkFilterTest.php +++ b/tests/LinkFilterTest.php @@ -63,6 +63,12 @@ class LinkFilterTest extends PHPUnit_Framework_TestCase count(self::$linkFilter->filter(LinkFilter::$FILTER_TAG, '')) ); + // Untagged only + $this->assertEquals( + self::$refDB->countUntaggedLinks(), + count(self::$linkFilter->filter(LinkFilter::$FILTER_TAG, false)) + ); + $this->assertEquals( ReferenceLinkDB::$NB_LINKS_TOTAL, count(self::$linkFilter->filter(LinkFilter::$FILTER_TEXT, '')) @@ -146,7 +152,7 @@ class LinkFilterTest extends PHPUnit_Framework_TestCase public function testFilterDay() { $this->assertEquals( - 3, + 4, count(self::$linkFilter->filter(LinkFilter::$FILTER_DAY, '20121206')) ); } @@ -339,7 +345,7 @@ class LinkFilterTest extends PHPUnit_Framework_TestCase ); $this->assertEquals( - 7, + ReferenceLinkDB::$NB_LINKS_TOTAL - 1, count(self::$linkFilter->filter(LinkFilter::$FILTER_TEXT, '-revolution')) ); } @@ -399,7 +405,7 @@ class LinkFilterTest extends PHPUnit_Framework_TestCase ); $this->assertEquals( - 7, + ReferenceLinkDB::$NB_LINKS_TOTAL - 1, count(self::$linkFilter->filter(LinkFilter::$FILTER_TAG, '-free')) ); } @@ -425,6 +431,13 @@ class LinkFilterTest extends PHPUnit_Framework_TestCase array('', $terms) )) ); + $this->assertEquals( + 1, + count(self::$linkFilter->filter( + LinkFilter::$FILTER_TAG | LinkFilter::$FILTER_TEXT, + array(false, 'PSR-2') + )) + ); $this->assertEquals( 1, count(self::$linkFilter->filter( -- cgit v1.2.3