From d592daea8343bb4dfecff5d97e93699581ccc58c Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Mon, 28 Nov 2016 18:24:15 +0100 Subject: Add a persistent 'shorturl' key to all links All existing link will keep their permalinks. New links will have smallhash generated with date+id. The purpose of this is to avoid collision between links due to their creation date. --- tests/LinkDBTest.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'tests/LinkDBTest.php') diff --git a/tests/LinkDBTest.php b/tests/LinkDBTest.php index bedc680e..1f62a34a 100644 --- a/tests/LinkDBTest.php +++ b/tests/LinkDBTest.php @@ -191,7 +191,7 @@ class LinkDBTest extends PHPUnit_Framework_TestCase 'url'=>'http://dum.my', 'description'=>'One more', 'private'=>0, - 'created'=> DateTime::createFromFormat('Ymd_His', '20150518_190000'), + 'created'=> DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20150518_190000'), 'tags'=>'unit test' ); $testDB[$link['id']] = $link; @@ -447,17 +447,17 @@ class LinkDBTest extends PHPUnit_Framework_TestCase */ public function testReorderLinksDesc() { - self::$publicLinkDB->reorder('ASC'); - $linkIdToTest = 42; - foreach (self::$publicLinkDB as $key => $value) { - $this->assertEquals($linkIdToTest, $key); - break; + self::$privateLinkDB->reorder('ASC'); + $linkIds = array(42, 4, 1, 0, 7, 6, 8, 41); + $cpt = 0; + foreach (self::$privateLinkDB as $key => $value) { + $this->assertEquals($linkIds[$cpt++], $key); } - self::$publicLinkDB->reorder('DESC'); - $linkIdToTest = 41; - foreach (self::$publicLinkDB as $key => $value) { - $this->assertEquals($linkIdToTest, $key); - break; + self::$privateLinkDB->reorder('DESC'); + $linkIds = array_reverse($linkIds); + $cpt = 0; + foreach (self::$privateLinkDB as $key => $value) { + $this->assertEquals($linkIds[$cpt++], $key); } } } -- cgit v1.2.3