aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/LinkDBTest.php1
-rw-r--r--tests/LinkFilterTest.php40
-rw-r--r--tests/utils/ReferenceLinkDB.php11
3 files changed, 47 insertions, 5 deletions
diff --git a/tests/LinkDBTest.php b/tests/LinkDBTest.php
index 765f771e..78f42e56 100644
--- a/tests/LinkDBTest.php
+++ b/tests/LinkDBTest.php
@@ -278,6 +278,7 @@ class LinkDBTest extends PHPUnit_Framework_TestCase
278 'stallman' => 1, 278 'stallman' => 1,
279 'free' => 1, 279 'free' => 1,
280 '-exclude' => 1, 280 '-exclude' => 1,
281 'stuff' => 2,
281 ), 282 ),
282 self::$publicLinkDB->allTags() 283 self::$publicLinkDB->allTags()
283 ); 284 );
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 }
diff --git a/tests/utils/ReferenceLinkDB.php b/tests/utils/ReferenceLinkDB.php
index da3e8c65..b64b58bf 100644
--- a/tests/utils/ReferenceLinkDB.php
+++ b/tests/utils/ReferenceLinkDB.php
@@ -16,13 +16,22 @@ class ReferenceLinkDB
16 $this->addLink( 16 $this->addLink(
17 'Free as in Freedom 2.0', 17 'Free as in Freedom 2.0',
18 'https://static.fsf.org/nosvn/faif-2.0.pdf', 18 'https://static.fsf.org/nosvn/faif-2.0.pdf',
19 'Richard Stallman and the Free Software Revolution', 19 'Richard Stallman and the Free Software Revolution. Read this.',
20 0, 20 0,
21 '20150310_114633', 21 '20150310_114633',
22 'free gnu software stallman -exclude' 22 'free gnu software stallman -exclude'
23 ); 23 );
24 24
25 $this->addLink( 25 $this->addLink(
26 'Note:',
27 'local',
28 'Stallman has a beard and is part of the Free Software Foundation (or not). Seriously, read this.',
29 0,
30 '20150310_114651',
31 ''
32 );
33
34 $this->addLink(
26 'MediaGoblin', 35 'MediaGoblin',
27 'http://mediagoblin.org/', 36 'http://mediagoblin.org/',
28 'A free software media publishing platform', 37 'A free software media publishing platform',