aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/LinkFilterTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/LinkFilterTest.php')
-rw-r--r--tests/LinkFilterTest.php79
1 files changed, 75 insertions, 4 deletions
diff --git a/tests/LinkFilterTest.php b/tests/LinkFilterTest.php
index 164af0d4..31fd4cf4 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
@@ -165,6 +165,17 @@ class LinkFilterTest extends PHPUnit_Framework_TestCase
165 } 165 }
166 166
167 /** 167 /**
168 * Full-text search - no result found.
169 */
170 public function testFilterFullTextNoResult()
171 {
172 $this->assertEquals(
173 0,
174 count(self::$linkFilter->filter(LinkFilter::$FILTER_TEXT, 'azertyuiop'))
175 );
176 }
177
178 /**
168 * Full-text search - result from a link's URL 179 * Full-text search - result from a link's URL
169 */ 180 */
170 public function testFilterFullTextURL() 181 public function testFilterFullTextURL()
@@ -222,7 +233,7 @@ class LinkFilterTest extends PHPUnit_Framework_TestCase
222 ); 233 );
223 234
224 $this->assertEquals( 235 $this->assertEquals(
225 2, 236 3,
226 count(self::$linkFilter->filter(LinkFilter::$FILTER_TEXT, '"free software"')) 237 count(self::$linkFilter->filter(LinkFilter::$FILTER_TEXT, '"free software"'))
227 ); 238 );
228 } 239 }
@@ -250,12 +261,72 @@ class LinkFilterTest extends PHPUnit_Framework_TestCase
250 public function testFilterFullTextMixed() 261 public function testFilterFullTextMixed()
251 { 262 {
252 $this->assertEquals( 263 $this->assertEquals(
253 2, 264 3,
254 count(self::$linkFilter->filter(LinkFilter::$FILTER_TEXT, 'free software')) 265 count(self::$linkFilter->filter(LinkFilter::$FILTER_TEXT, 'free software'))
255 ); 266 );
256 } 267 }
257 268
258 /** 269 /**
270 * Full-text search - test exclusion with '-'.
271 */
272 public function testExcludeSearch()
273 {
274 $this->assertEquals(
275 1,
276 count(self::$linkFilter->filter(LinkFilter::$FILTER_TEXT, 'free -gnu'))
277 );
278
279 $this->assertEquals(
280 6,
281 count(self::$linkFilter->filter(LinkFilter::$FILTER_TEXT, '-revolution'))
282 );
283 }
284
285 /**
286 * Full-text search - test AND, exact terms and exclusion combined, across fields.
287 */
288 public function testMultiSearch()
289 {
290 $this->assertEquals(
291 2,
292 count(self::$linkFilter->filter(
293 LinkFilter::$FILTER_TEXT,
294 '"Free Software " stallman "read this" @website stuff'
295 ))
296 );
297
298 $this->assertEquals(
299 1,
300 count(self::$linkFilter->filter(
301 LinkFilter::$FILTER_TEXT,
302 '"free software " stallman "read this" -beard @website stuff'
303 ))
304 );
305 }
306
307 /**
308 * Full-text search - make sure that exact search won't work across fields.
309 */
310 public function testSearchExactTermMultiFieldsKo()
311 {
312 $this->assertEquals(
313 0,
314 count(self::$linkFilter->filter(
315 LinkFilter::$FILTER_TEXT,
316 '"designer naming"'
317 ))
318 );
319
320 $this->assertEquals(
321 0,
322 count(self::$linkFilter->filter(
323 LinkFilter::$FILTER_TEXT,
324 '"designernaming"'
325 ))
326 );
327 }
328
329 /**
259 * Tag search with exclusion. 330 * Tag search with exclusion.
260 */ 331 */
261 public function testTagFilterWithExclusion() 332 public function testTagFilterWithExclusion()
@@ -266,7 +337,7 @@ class LinkFilterTest extends PHPUnit_Framework_TestCase
266 ); 337 );
267 338
268 $this->assertEquals( 339 $this->assertEquals(
269 5, 340 6,
270 count(self::$linkFilter->filter(LinkFilter::$FILTER_TAG, '-free')) 341 count(self::$linkFilter->filter(LinkFilter::$FILTER_TAG, '-free'))
271 ); 342 );
272 } 343 }