aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/bookmark/LinkDBTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/bookmark/LinkDBTest.php')
-rw-r--r--tests/bookmark/LinkDBTest.php25
1 files changed, 12 insertions, 13 deletions
diff --git a/tests/bookmark/LinkDBTest.php b/tests/bookmark/LinkDBTest.php
index 5bbdcea1..ffe03cc5 100644
--- a/tests/bookmark/LinkDBTest.php
+++ b/tests/bookmark/LinkDBTest.php
@@ -49,17 +49,7 @@ class LinkDBTest extends \PHPUnit\Framework\TestCase
49 * - by tag, 49 * - by tag,
50 * - by text, 50 * - by text,
51 * - etc. 51 * - etc.
52 */ 52 *
53 public static function setUpBeforeClass()
54 {
55 self::$refDB = new ReferenceLinkDB();
56 self::$refDB->write(self::$testDatastore);
57
58 self::$publicLinkDB = new LinkDB(self::$testDatastore, false, false);
59 self::$privateLinkDB = new LinkDB(self::$testDatastore, true, false);
60 }
61
62 /**
63 * Resets test data for each test 53 * Resets test data for each test
64 */ 54 */
65 protected function setUp() 55 protected function setUp()
@@ -67,6 +57,12 @@ class LinkDBTest extends \PHPUnit\Framework\TestCase
67 if (file_exists(self::$testDatastore)) { 57 if (file_exists(self::$testDatastore)) {
68 unlink(self::$testDatastore); 58 unlink(self::$testDatastore);
69 } 59 }
60
61 self::$refDB = new ReferenceLinkDB();
62 self::$refDB->write(self::$testDatastore);
63
64 self::$publicLinkDB = new LinkDB(self::$testDatastore, false, false);
65 self::$privateLinkDB = new LinkDB(self::$testDatastore, true, false);
70 } 66 }
71 67
72 /** 68 /**
@@ -191,7 +187,7 @@ class LinkDBTest extends \PHPUnit\Framework\TestCase
191 $dbSize = sizeof($testDB); 187 $dbSize = sizeof($testDB);
192 188
193 $link = array( 189 $link = array(
194 'id' => 42, 190 'id' => 43,
195 'title' => 'an additional link', 191 'title' => 'an additional link',
196 'url' => 'http://dum.my', 192 'url' => 'http://dum.my',
197 'description' => 'One more', 193 'description' => 'One more',
@@ -626,7 +622,7 @@ class LinkDBTest extends \PHPUnit\Framework\TestCase
626 */ 622 */
627 public function testConsistentOrder() 623 public function testConsistentOrder()
628 { 624 {
629 $nextId = 42; 625 $nextId = 43;
630 $creation = DateTime::createFromFormat('Ymd_His', '20190807_130444'); 626 $creation = DateTime::createFromFormat('Ymd_His', '20190807_130444');
631 $linkDB = new LinkDB(self::$testDatastore, true, false); 627 $linkDB = new LinkDB(self::$testDatastore, true, false);
632 for ($i = 0; $i < 4; ++$i) { 628 for ($i = 0; $i < 4; ++$i) {
@@ -646,6 +642,9 @@ class LinkDBTest extends \PHPUnit\Framework\TestCase
646 $linkDB = new LinkDB(self::$testDatastore, true, false); 642 $linkDB = new LinkDB(self::$testDatastore, true, false);
647 $count = 3; 643 $count = 3;
648 foreach ($linkDB as $link) { 644 foreach ($linkDB as $link) {
645 if ($link['sticky'] === true) {
646 continue;
647 }
649 $this->assertEquals($nextId + $count, $link['id']); 648 $this->assertEquals($nextId + $count, $link['id']);
650 $this->assertEquals('http://'. $count, $link['url']); 649 $this->assertEquals('http://'. $count, $link['url']);
651 if (--$count < 0) { 650 if (--$count < 0) {