aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/LinkFilterTest.php73
1 files changed, 63 insertions, 10 deletions
diff --git a/tests/LinkFilterTest.php b/tests/LinkFilterTest.php
index 21d680a5..37d5ca30 100644
--- a/tests/LinkFilterTest.php
+++ b/tests/LinkFilterTest.php
@@ -13,12 +13,17 @@ class LinkFilterTest extends PHPUnit_Framework_TestCase
13 protected static $linkFilter; 13 protected static $linkFilter;
14 14
15 /** 15 /**
16 * @var ReferenceLinkDB instance
17 */
18 protected static $refDB;
19
20 /**
16 * Instanciate linkFilter with ReferenceLinkDB data. 21 * Instanciate linkFilter with ReferenceLinkDB data.
17 */ 22 */
18 public static function setUpBeforeClass() 23 public static function setUpBeforeClass()
19 { 24 {
20 $refDB = new ReferenceLinkDB(); 25 self::$refDB = new ReferenceLinkDB();
21 self::$linkFilter = new LinkFilter($refDB->getLinks()); 26 self::$linkFilter = new LinkFilter(self::$refDB->getLinks());
22 } 27 }
23 28
24 /** 29 /**
@@ -27,14 +32,30 @@ class LinkFilterTest extends PHPUnit_Framework_TestCase
27 public function testFilter() 32 public function testFilter()
28 { 33 {
29 $this->assertEquals( 34 $this->assertEquals(
30 ReferenceLinkDB::$NB_LINKS_TOTAL, 35 self::$refDB->countLinks(),
31 count(self::$linkFilter->filter('', '')) 36 count(self::$linkFilter->filter('', ''))
32 ); 37 );
33 38
39 $this->assertEquals(
40 self::$refDB->countLinks(),
41 count(self::$linkFilter->filter('', '', 'all'))
42 );
43
44 $this->assertEquals(
45 self::$refDB->countLinks(),
46 count(self::$linkFilter->filter('', '', 'randomstr'))
47 );
48
34 // Private only. 49 // Private only.
35 $this->assertEquals( 50 $this->assertEquals(
36 2, 51 self::$refDB->countPrivateLinks(),
37 count(self::$linkFilter->filter('', '', false, true)) 52 count(self::$linkFilter->filter('', '', false, 'private'))
53 );
54
55 // Public only.
56 $this->assertEquals(
57 self::$refDB->countPublicLinks(),
58 count(self::$linkFilter->filter('', '', false, 'public'))
38 ); 59 );
39 60
40 $this->assertEquals( 61 $this->assertEquals(
@@ -58,10 +79,26 @@ class LinkFilterTest extends PHPUnit_Framework_TestCase
58 count(self::$linkFilter->filter(LinkFilter::$FILTER_TAG, 'web', false)) 79 count(self::$linkFilter->filter(LinkFilter::$FILTER_TAG, 'web', false))
59 ); 80 );
60 81
82 $this->assertEquals(
83 4,
84 count(self::$linkFilter->filter(LinkFilter::$FILTER_TAG, 'web', false, 'all'))
85 );
86
87 $this->assertEquals(
88 4,
89 count(self::$linkFilter->filter(LinkFilter::$FILTER_TAG, 'web', false, 'default-blabla'))
90 );
91
61 // Private only. 92 // Private only.
62 $this->assertEquals( 93 $this->assertEquals(
63 1, 94 1,
64 count(self::$linkFilter->filter(LinkFilter::$FILTER_TAG, 'web', false, true)) 95 count(self::$linkFilter->filter(LinkFilter::$FILTER_TAG, 'web', false, 'private'))
96 );
97
98 // Public only.
99 $this->assertEquals(
100 3,
101 count(self::$linkFilter->filter(LinkFilter::$FILTER_TAG, 'web', false, 'public'))
65 ); 102 );
66 } 103 }
67 104
@@ -253,14 +290,30 @@ class LinkFilterTest extends PHPUnit_Framework_TestCase
253 public function testFilterFullTextTags() 290 public function testFilterFullTextTags()
254 { 291 {
255 $this->assertEquals( 292 $this->assertEquals(
256 2, 293 6,
257 count(self::$linkFilter->filter(LinkFilter::$FILTER_TEXT, 'gnu')) 294 count(self::$linkFilter->filter(LinkFilter::$FILTER_TEXT, 'web'))
295 );
296
297 $this->assertEquals(
298 6,
299 count(self::$linkFilter->filter(LinkFilter::$FILTER_TEXT, 'web', 'all'))
300 );
301
302 $this->assertEquals(
303 6,
304 count(self::$linkFilter->filter(LinkFilter::$FILTER_TEXT, 'web', 'bla'))
258 ); 305 );
259 306
260 // Private only. 307 // Private only.
261 $this->assertEquals( 308 $this->assertEquals(
262 1, 309 1,
263 count(self::$linkFilter->filter(LinkFilter::$FILTER_TEXT, 'web', false, true)) 310 count(self::$linkFilter->filter(LinkFilter::$FILTER_TEXT, 'web', false, 'private'))
311 );
312
313 // Public only.
314 $this->assertEquals(
315 5,
316 count(self::$linkFilter->filter(LinkFilter::$FILTER_TEXT, 'web', false, 'public'))
264 ); 317 );
265 } 318 }
266 319
@@ -409,7 +462,7 @@ class LinkFilterTest extends PHPUnit_Framework_TestCase
409 LinkFilter::$FILTER_TAG, 462 LinkFilter::$FILTER_TAG,
410 $hashtag, 463 $hashtag,
411 false, 464 false,
412 true 465 'private'
413 )) 466 ))
414 ); 467 );
415 } 468 }