diff options
author | VirtualTam <virtualtam@flibidi.net> | 2019-02-23 16:27:33 +0100 |
---|---|---|
committer | VirtualTam <virtualtam@flibidi.net> | 2019-02-23 16:27:33 +0100 |
commit | 43c77f658a905e2def6aeca4c092683977cd0c55 (patch) | |
tree | cb0dc273a315a777847d251f856625b2fc779c04 /tests/LinkDBTest.php | |
parent | 630ebca2b6359e942e5b6c057cca2b6069c1093a (diff) | |
parent | 1826e383ecf501302974132fd443cf1ca06e10f6 (diff) | |
download | Shaarli-43c77f658a905e2def6aeca4c092683977cd0c55.tar.gz Shaarli-43c77f658a905e2def6aeca4c092683977cd0c55.tar.zst Shaarli-43c77f658a905e2def6aeca4c092683977cd0c55.zip |
Merge commit '1826e383ecf501302974132fd443cf1ca06e10f6' into v0.10
Diffstat (limited to 'tests/LinkDBTest.php')
-rw-r--r-- | tests/LinkDBTest.php | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/tests/LinkDBTest.php b/tests/LinkDBTest.php index 3b980878..c763c0cb 100644 --- a/tests/LinkDBTest.php +++ b/tests/LinkDBTest.php | |||
@@ -239,12 +239,12 @@ class LinkDBTest extends PHPUnit_Framework_TestCase | |||
239 | public function testDays() | 239 | public function testDays() |
240 | { | 240 | { |
241 | $this->assertEquals( | 241 | $this->assertEquals( |
242 | array('20100310', '20121206', '20130614', '20150310'), | 242 | array('20100309', '20100310', '20121206', '20121207', '20130614', '20150310'), |
243 | self::$publicLinkDB->days() | 243 | self::$publicLinkDB->days() |
244 | ); | 244 | ); |
245 | 245 | ||
246 | $this->assertEquals( | 246 | $this->assertEquals( |
247 | array('20100310', '20121206', '20130614', '20141125', '20150310'), | 247 | array('20100309', '20100310', '20121206', '20121207', '20130614', '20141125', '20150310'), |
248 | self::$privateLinkDB->days() | 248 | self::$privateLinkDB->days() |
249 | ); | 249 | ); |
250 | } | 250 | } |
@@ -362,7 +362,7 @@ class LinkDBTest extends PHPUnit_Framework_TestCase | |||
362 | public function testLinkRealUrlWithoutRedirector() | 362 | public function testLinkRealUrlWithoutRedirector() |
363 | { | 363 | { |
364 | $db = new LinkDB(self::$testDatastore, false, false); | 364 | $db = new LinkDB(self::$testDatastore, false, false); |
365 | foreach($db as $link) { | 365 | foreach ($db as $link) { |
366 | $this->assertEquals($link['url'], $link['real_url']); | 366 | $this->assertEquals($link['url'], $link['real_url']); |
367 | } | 367 | } |
368 | } | 368 | } |
@@ -374,13 +374,13 @@ class LinkDBTest extends PHPUnit_Framework_TestCase | |||
374 | { | 374 | { |
375 | $redirector = 'http://redirector.to?'; | 375 | $redirector = 'http://redirector.to?'; |
376 | $db = new LinkDB(self::$testDatastore, false, false, $redirector); | 376 | $db = new LinkDB(self::$testDatastore, false, false, $redirector); |
377 | foreach($db as $link) { | 377 | foreach ($db as $link) { |
378 | $this->assertStringStartsWith($redirector, $link['real_url']); | 378 | $this->assertStringStartsWith($redirector, $link['real_url']); |
379 | $this->assertNotFalse(strpos($link['real_url'], urlencode('://'))); | 379 | $this->assertNotFalse(strpos($link['real_url'], urlencode('://'))); |
380 | } | 380 | } |
381 | 381 | ||
382 | $db = new LinkDB(self::$testDatastore, false, false, $redirector, false); | 382 | $db = new LinkDB(self::$testDatastore, false, false, $redirector, false); |
383 | foreach($db as $link) { | 383 | foreach ($db as $link) { |
384 | $this->assertStringStartsWith($redirector, $link['real_url']); | 384 | $this->assertStringStartsWith($redirector, $link['real_url']); |
385 | $this->assertFalse(strpos($link['real_url'], urlencode('://'))); | 385 | $this->assertFalse(strpos($link['real_url'], urlencode('://'))); |
386 | } | 386 | } |
@@ -475,13 +475,15 @@ class LinkDBTest extends PHPUnit_Framework_TestCase | |||
475 | public function testReorderLinksDesc() | 475 | public function testReorderLinksDesc() |
476 | { | 476 | { |
477 | self::$privateLinkDB->reorder('ASC'); | 477 | self::$privateLinkDB->reorder('ASC'); |
478 | $linkIds = array(42, 4, 9, 1, 0, 7, 6, 8, 41); | 478 | $stickyIds = [11, 10]; |
479 | $standardIds = [42, 4, 9, 1, 0, 7, 6, 8, 41]; | ||
480 | $linkIds = array_merge($stickyIds, $standardIds); | ||
479 | $cpt = 0; | 481 | $cpt = 0; |
480 | foreach (self::$privateLinkDB as $key => $value) { | 482 | foreach (self::$privateLinkDB as $key => $value) { |
481 | $this->assertEquals($linkIds[$cpt++], $key); | 483 | $this->assertEquals($linkIds[$cpt++], $key); |
482 | } | 484 | } |
483 | self::$privateLinkDB->reorder('DESC'); | 485 | self::$privateLinkDB->reorder('DESC'); |
484 | $linkIds = array_reverse($linkIds); | 486 | $linkIds = array_merge(array_reverse($stickyIds), array_reverse($standardIds)); |
485 | $cpt = 0; | 487 | $cpt = 0; |
486 | foreach (self::$privateLinkDB as $key => $value) { | 488 | foreach (self::$privateLinkDB as $key => $value) { |
487 | $this->assertEquals($linkIds[$cpt++], $key); | 489 | $this->assertEquals($linkIds[$cpt++], $key); |