aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorVirtualTam <virtualtam@flibidi.net>2015-06-23 22:34:07 +0200
committernodiscc <nodiscc@gmail.com>2015-06-24 00:26:59 +0200
commit9f15ca9ee76bc36832f12a952005fdaf52e2559d (patch)
treeb29e109d2eccad7b13a6dd5d6f59571f4023686f /tests
parentae630270109bf78b5f561c887d35b7b099d30271 (diff)
downloadShaarli-9f15ca9ee76bc36832f12a952005fdaf52e2559d.tar.gz
Shaarli-9f15ca9ee76bc36832f12a952005fdaf52e2559d.tar.zst
Shaarli-9f15ca9ee76bc36832f12a952005fdaf52e2559d.zip
LinkDB: add 'hidePublicLinks' parameter to the constructor
Fixes #236 Relates to #237 Signed-off-by: VirtualTam <virtualtam@flibidi.net>
Diffstat (limited to 'tests')
-rw-r--r--tests/LinkDBTest.php37
1 files changed, 27 insertions, 10 deletions
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
41 self::$refDB->write(self::$testDatastore, PHPPREFIX, PHPSUFFIX); 41 self::$refDB->write(self::$testDatastore, PHPPREFIX, PHPSUFFIX);
42 42
43 $GLOBALS['config']['DATASTORE'] = self::$testDatastore; 43 $GLOBALS['config']['DATASTORE'] = self::$testDatastore;
44 self::$publicLinkDB = new LinkDB(false); 44 self::$publicLinkDB = new LinkDB(false, false);
45 self::$privateLinkDB = new LinkDB(true); 45 self::$privateLinkDB = new LinkDB(true, false);
46 } 46 }
47 47
48 /** 48 /**
@@ -76,7 +76,7 @@ class LinkDBTest extends PHPUnit_Framework_TestCase
76 */ 76 */
77 public function testConstructLoggedIn() 77 public function testConstructLoggedIn()
78 { 78 {
79 new LinkDB(true); 79 new LinkDB(true, false);
80 $this->assertFileExists(self::$testDatastore); 80 $this->assertFileExists(self::$testDatastore);
81 } 81 }
82 82
@@ -85,7 +85,7 @@ class LinkDBTest extends PHPUnit_Framework_TestCase
85 */ 85 */
86 public function testConstructLoggedOut() 86 public function testConstructLoggedOut()
87 { 87 {
88 new LinkDB(false); 88 new LinkDB(false, false);
89 $this->assertFileExists(self::$testDatastore); 89 $this->assertFileExists(self::$testDatastore);
90 } 90 }
91 91
@@ -98,7 +98,7 @@ class LinkDBTest extends PHPUnit_Framework_TestCase
98 public function testConstructDatastoreNotWriteable() 98 public function testConstructDatastoreNotWriteable()
99 { 99 {
100 $GLOBALS['config']['DATASTORE'] = 'null/store.db'; 100 $GLOBALS['config']['DATASTORE'] = 'null/store.db';
101 new LinkDB(false); 101 new LinkDB(false, false);
102 } 102 }
103 103
104 /** 104 /**
@@ -106,7 +106,7 @@ class LinkDBTest extends PHPUnit_Framework_TestCase
106 */ 106 */
107 public function testCheckDBNew() 107 public function testCheckDBNew()
108 { 108 {
109 $linkDB = new LinkDB(false); 109 $linkDB = new LinkDB(false, false);
110 unlink(self::$testDatastore); 110 unlink(self::$testDatastore);
111 $this->assertFileNotExists(self::$testDatastore); 111 $this->assertFileNotExists(self::$testDatastore);
112 112
@@ -126,7 +126,7 @@ class LinkDBTest extends PHPUnit_Framework_TestCase
126 */ 126 */
127 public function testCheckDBLoad() 127 public function testCheckDBLoad()
128 { 128 {
129 $linkDB = new LinkDB(false); 129 $linkDB = new LinkDB(false, false);
130 $this->assertEquals( 130 $this->assertEquals(
131 self::$dummyDatastoreSHA1, 131 self::$dummyDatastoreSHA1,
132 sha1_file(self::$testDatastore) 132 sha1_file(self::$testDatastore)
@@ -148,7 +148,7 @@ class LinkDBTest extends PHPUnit_Framework_TestCase
148 public function testReadEmptyDB() 148 public function testReadEmptyDB()
149 { 149 {
150 file_put_contents(self::$testDatastore, PHPPREFIX.'S7QysKquBQA='.PHPSUFFIX); 150 file_put_contents(self::$testDatastore, PHPPREFIX.'S7QysKquBQA='.PHPSUFFIX);
151 $emptyDB = new LinkDB(false); 151 $emptyDB = new LinkDB(false, false);
152 $this->assertEquals(0, sizeof($emptyDB)); 152 $this->assertEquals(0, sizeof($emptyDB));
153 $this->assertEquals(0, count($emptyDB)); 153 $this->assertEquals(0, count($emptyDB));
154 } 154 }
@@ -180,7 +180,7 @@ class LinkDBTest extends PHPUnit_Framework_TestCase
180 */ 180 */
181 public function testSaveDB() 181 public function testSaveDB()
182 { 182 {
183 $testDB = new LinkDB(true); 183 $testDB = new LinkDB(true, false);
184 $dbSize = sizeof($testDB); 184 $dbSize = sizeof($testDB);
185 185
186 $link = array( 186 $link = array(
@@ -198,7 +198,7 @@ class LinkDBTest extends PHPUnit_Framework_TestCase
198 198
199 $testDB->savedb(); 199 $testDB->savedb();
200 200
201 $testDB = new LinkDB(true); 201 $testDB = new LinkDB(true, false);
202 $this->assertEquals($dbSize + 1, sizeof($testDB)); 202 $this->assertEquals($dbSize + 1, sizeof($testDB));
203 } 203 }
204 204
@@ -218,6 +218,23 @@ class LinkDBTest extends PHPUnit_Framework_TestCase
218 } 218 }
219 219
220 /** 220 /**
221 * Count existing links - public links hidden
222 */
223 public function testCountHiddenPublic()
224 {
225 $linkDB = new LinkDB(false, true);
226
227 $this->assertEquals(
228 0,
229 $linkDB->count()
230 );
231 $this->assertEquals(
232 0,
233 $linkDB->count()
234 );
235 }
236
237 /**
221 * List the days for which links have been posted 238 * List the days for which links have been posted
222 */ 239 */
223 public function testDays() 240 public function testDays()