From 89baf23ddfaf82cc663e26f76c307ef8e4bf4b02 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sat, 12 Mar 2016 17:54:56 +0100 Subject: FeedBuilder unit tests --- tests/LinkFilterTest.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'tests/LinkFilterTest.php') diff --git a/tests/LinkFilterTest.php b/tests/LinkFilterTest.php index ef1cc10a..f991a9c9 100644 --- a/tests/LinkFilterTest.php +++ b/tests/LinkFilterTest.php @@ -12,8 +12,6 @@ class LinkFilterTest extends PHPUnit_Framework_TestCase */ protected static $linkFilter; - protected static $NB_LINKS_REFDB = 7; - /** * Instanciate linkFilter with ReferenceLinkDB data. */ @@ -29,7 +27,7 @@ class LinkFilterTest extends PHPUnit_Framework_TestCase public function testFilter() { $this->assertEquals( - self::$NB_LINKS_REFDB, + ReferenceLinkDB::$NB_LINKS_TOTAL, count(self::$linkFilter->filter('', '')) ); @@ -40,12 +38,12 @@ class LinkFilterTest extends PHPUnit_Framework_TestCase ); $this->assertEquals( - self::$NB_LINKS_REFDB, + ReferenceLinkDB::$NB_LINKS_TOTAL, count(self::$linkFilter->filter(LinkFilter::$FILTER_TAG, '')) ); $this->assertEquals( - self::$NB_LINKS_REFDB, + ReferenceLinkDB::$NB_LINKS_TOTAL, count(self::$linkFilter->filter(LinkFilter::$FILTER_TEXT, '')) ); } @@ -383,7 +381,7 @@ class LinkFilterTest extends PHPUnit_Framework_TestCase )) ); $this->assertEquals( - self::$NB_LINKS_REFDB, + ReferenceLinkDB::$NB_LINKS_TOTAL, count(self::$linkFilter->filter( LinkFilter::$FILTER_TAG | LinkFilter::$FILTER_TEXT, '' -- cgit v1.2.3 From 528a6f8a232c060faf024008e4f8a09b4aa8dabc Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Mon, 21 Mar 2016 21:40:49 +0100 Subject: Refactor filter in LinkDB * search type now carried by LinkDB in order to factorize code between different search sources. * LinkDB->filter split in 3 method: filterSearch, filterHash, filterDay (we know what type of filter is needed). * filterHash now throw a LinkNotFoundException if it doesn't exist: internal implementation choice, still displays a 404. * Smallhash regex has been rewritten. * Unit tests update --- tests/LinkFilterTest.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'tests/LinkFilterTest.php') diff --git a/tests/LinkFilterTest.php b/tests/LinkFilterTest.php index f991a9c9..1620bb78 100644 --- a/tests/LinkFilterTest.php +++ b/tests/LinkFilterTest.php @@ -165,13 +165,12 @@ class LinkFilterTest extends PHPUnit_Framework_TestCase /** * No link for this hash + * + * @expectedException LinkNotFoundException */ public function testFilterUnknownSmallHash() { - $this->assertEquals( - 0, - count(self::$linkFilter->filter(LinkFilter::$FILTER_HASH, 'Iblaah')) - ); + self::$linkFilter->filter(LinkFilter::$FILTER_HASH, 'Iblaah'); } /** -- cgit v1.2.3