From 9f15ca9ee76bc36832f12a952005fdaf52e2559d Mon Sep 17 00:00:00 2001 From: VirtualTam Date: Tue, 23 Jun 2015 22:34:07 +0200 Subject: LinkDB: add 'hidePublicLinks' parameter to the constructor Fixes #236 Relates to #237 Signed-off-by: VirtualTam --- tests/LinkDBTest.php | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) (limited to 'tests/LinkDBTest.php') diff --git a/tests/LinkDBTest.php b/tests/LinkDBTest.php index bbe4e026..f67d4d9b 100644 --- a/tests/LinkDBTest.php +++ b/tests/LinkDBTest.php @@ -41,8 +41,8 @@ class LinkDBTest extends PHPUnit_Framework_TestCase self::$refDB->write(self::$testDatastore, PHPPREFIX, PHPSUFFIX); $GLOBALS['config']['DATASTORE'] = self::$testDatastore; - self::$publicLinkDB = new LinkDB(false); - self::$privateLinkDB = new LinkDB(true); + self::$publicLinkDB = new LinkDB(false, false); + self::$privateLinkDB = new LinkDB(true, false); } /** @@ -76,7 +76,7 @@ class LinkDBTest extends PHPUnit_Framework_TestCase */ public function testConstructLoggedIn() { - new LinkDB(true); + new LinkDB(true, false); $this->assertFileExists(self::$testDatastore); } @@ -85,7 +85,7 @@ class LinkDBTest extends PHPUnit_Framework_TestCase */ public function testConstructLoggedOut() { - new LinkDB(false); + new LinkDB(false, false); $this->assertFileExists(self::$testDatastore); } @@ -98,7 +98,7 @@ class LinkDBTest extends PHPUnit_Framework_TestCase public function testConstructDatastoreNotWriteable() { $GLOBALS['config']['DATASTORE'] = 'null/store.db'; - new LinkDB(false); + new LinkDB(false, false); } /** @@ -106,7 +106,7 @@ class LinkDBTest extends PHPUnit_Framework_TestCase */ public function testCheckDBNew() { - $linkDB = new LinkDB(false); + $linkDB = new LinkDB(false, false); unlink(self::$testDatastore); $this->assertFileNotExists(self::$testDatastore); @@ -126,7 +126,7 @@ class LinkDBTest extends PHPUnit_Framework_TestCase */ public function testCheckDBLoad() { - $linkDB = new LinkDB(false); + $linkDB = new LinkDB(false, false); $this->assertEquals( self::$dummyDatastoreSHA1, sha1_file(self::$testDatastore) @@ -148,7 +148,7 @@ class LinkDBTest extends PHPUnit_Framework_TestCase public function testReadEmptyDB() { file_put_contents(self::$testDatastore, PHPPREFIX.'S7QysKquBQA='.PHPSUFFIX); - $emptyDB = new LinkDB(false); + $emptyDB = new LinkDB(false, false); $this->assertEquals(0, sizeof($emptyDB)); $this->assertEquals(0, count($emptyDB)); } @@ -180,7 +180,7 @@ class LinkDBTest extends PHPUnit_Framework_TestCase */ public function testSaveDB() { - $testDB = new LinkDB(true); + $testDB = new LinkDB(true, false); $dbSize = sizeof($testDB); $link = array( @@ -198,7 +198,7 @@ class LinkDBTest extends PHPUnit_Framework_TestCase $testDB->savedb(); - $testDB = new LinkDB(true); + $testDB = new LinkDB(true, false); $this->assertEquals($dbSize + 1, sizeof($testDB)); } @@ -217,6 +217,23 @@ class LinkDBTest extends PHPUnit_Framework_TestCase ); } + /** + * Count existing links - public links hidden + */ + public function testCountHiddenPublic() + { + $linkDB = new LinkDB(false, true); + + $this->assertEquals( + 0, + $linkDB->count() + ); + $this->assertEquals( + 0, + $linkDB->count() + ); + } + /** * List the days for which links have been posted */ -- cgit v1.2.3