aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/LinkFilterTest.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2016-02-01 20:33:58 +0100
committerArthurHoaro <arthur@hoa.ro>2016-02-15 21:38:40 +0100
commitbedd176a5406003631da42366736fd5ebae29135 (patch)
treeb7577d5f5fcb4534d293a4a6c59d84e8b0f48d42 /tests/LinkFilterTest.php
parent07c2f73543b358d39b3751c8542966794f28db03 (diff)
downloadShaarli-bedd176a5406003631da42366736fd5ebae29135.tar.gz
Shaarli-bedd176a5406003631da42366736fd5ebae29135.tar.zst
Shaarli-bedd176a5406003631da42366736fd5ebae29135.zip
Improved search: combine AND, exact terms and exclude search.
Diffstat (limited to 'tests/LinkFilterTest.php')
-rw-r--r--tests/LinkFilterTest.php40
1 files changed, 36 insertions, 4 deletions
diff --git a/tests/LinkFilterTest.php b/tests/LinkFilterTest.php
index 164af0d4..4d754d25 100644
--- a/tests/LinkFilterTest.php
+++ b/tests/LinkFilterTest.php
@@ -27,7 +27,7 @@ class LinkFilterTest extends PHPUnit_Framework_TestCase
27 public function testFilter() 27 public function testFilter()
28 { 28 {
29 $this->assertEquals( 29 $this->assertEquals(
30 6, 30 7,
31 count(self::$linkFilter->filter('', '')) 31 count(self::$linkFilter->filter('', ''))
32 ); 32 );
33 33
@@ -222,7 +222,7 @@ class LinkFilterTest extends PHPUnit_Framework_TestCase
222 ); 222 );
223 223
224 $this->assertEquals( 224 $this->assertEquals(
225 2, 225 3,
226 count(self::$linkFilter->filter(LinkFilter::$FILTER_TEXT, '"free software"')) 226 count(self::$linkFilter->filter(LinkFilter::$FILTER_TEXT, '"free software"'))
227 ); 227 );
228 } 228 }
@@ -250,12 +250,44 @@ class LinkFilterTest extends PHPUnit_Framework_TestCase
250 public function testFilterFullTextMixed() 250 public function testFilterFullTextMixed()
251 { 251 {
252 $this->assertEquals( 252 $this->assertEquals(
253 2, 253 3,
254 count(self::$linkFilter->filter(LinkFilter::$FILTER_TEXT, 'free software')) 254 count(self::$linkFilter->filter(LinkFilter::$FILTER_TEXT, 'free software'))
255 ); 255 );
256 } 256 }
257 257
258 /** 258 /**
259 * Full-text search - test exclusion with '-'.
260 */
261 public function testExcludeSearch()
262 {
263 $this->assertEquals(
264 1,
265 count(self::$linkFilter->filter(LinkFilter::$FILTER_TEXT, 'free -software'))
266 );
267
268 $this->assertEquals(
269 7,
270 count(self::$linkFilter->filter(LinkFilter::$FILTER_TEXT, '-software'))
271 );
272 }
273
274 /**
275 * Full-text search - test AND, exact terms and exclusion combined.
276 */
277 public function testMultiSearch()
278 {
279 $this->assertEquals(
280 2,
281 count(self::$linkFilter->filter(LinkFilter::$FILTER_TEXT, '"Free Software " stallman "read this"'))
282 );
283
284 $this->assertEquals(
285 1,
286 count(self::$linkFilter->filter(LinkFilter::$FILTER_TEXT, '"free software " stallman "read this" -beard'))
287 );
288 }
289
290 /**
259 * Tag search with exclusion. 291 * Tag search with exclusion.
260 */ 292 */
261 public function testTagFilterWithExclusion() 293 public function testTagFilterWithExclusion()
@@ -266,7 +298,7 @@ class LinkFilterTest extends PHPUnit_Framework_TestCase
266 ); 298 );
267 299
268 $this->assertEquals( 300 $this->assertEquals(
269 5, 301 6,
270 count(self::$linkFilter->filter(LinkFilter::$FILTER_TAG, '-free')) 302 count(self::$linkFilter->filter(LinkFilter::$FILTER_TAG, '-free'))
271 ); 303 );
272 } 304 }