aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/LinkDBTest.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2017-08-05 09:59:03 +0200
committerGitHub <noreply@github.com>2017-08-05 09:59:03 +0200
commit1fdb40fc169b42af7622610c4f088688de231118 (patch)
tree4b5169150b1abcacf00f1ac2317aa633c37eaa26 /tests/LinkDBTest.php
parentf09e1e318e0b1c72aa659c20b715be508009175f (diff)
parent3b67b22225c54b28c5ea8b118710ef450016fb86 (diff)
downloadShaarli-1fdb40fc169b42af7622610c4f088688de231118.tar.gz
Shaarli-1fdb40fc169b42af7622610c4f088688de231118.tar.zst
Shaarli-1fdb40fc169b42af7622610c4f088688de231118.zip
Merge pull request #887 from ArthurHoaro/hotfix/dash-tag-rename
Make sure that the tag exists before altering/removing it
Diffstat (limited to 'tests/LinkDBTest.php')
-rw-r--r--tests/LinkDBTest.php55
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/LinkDBTest.php b/tests/LinkDBTest.php
index 25438277..5b2f3667 100644
--- a/tests/LinkDBTest.php
+++ b/tests/LinkDBTest.php
@@ -487,4 +487,59 @@ class LinkDBTest extends PHPUnit_Framework_TestCase
487 $this->assertEquals($linkIds[$cpt++], $key); 487 $this->assertEquals($linkIds[$cpt++], $key);
488 } 488 }
489 } 489 }
490
491 /**
492 * Test rename tag with a valid value present in multiple links
493 */
494 public function testRenameTagMultiple()
495 {
496 self::$refDB->write(self::$testDatastore);
497 $linkDB = new LinkDB(self::$testDatastore, true, false);
498
499 $res = $linkDB->renameTag('cartoon', 'Taz');
500 $this->assertEquals(3, count($res));
501 $this->assertContains(' Taz ', $linkDB[4]['tags']);
502 $this->assertContains(' Taz ', $linkDB[1]['tags']);
503 $this->assertContains(' Taz ', $linkDB[0]['tags']);
504 }
505
506 /**
507 * Test rename tag with a valid value
508 */
509 public function testRenameTagCaseSensitive()
510 {
511 self::$refDB->write(self::$testDatastore);
512 $linkDB = new LinkDB(self::$testDatastore, true, false, '');
513
514 $res = $linkDB->renameTag('sTuff', 'Taz');
515 $this->assertEquals(1, count($res));
516 $this->assertEquals('Taz', $linkDB[41]['tags']);
517 }
518
519 /**
520 * Test rename tag with invalid values
521 */
522 public function testRenameTagInvalid()
523 {
524 $linkDB = new LinkDB(self::$testDatastore, false, false);
525
526 $this->assertFalse($linkDB->renameTag('', 'test'));
527 $this->assertFalse($linkDB->renameTag('', ''));
528 // tag non existent
529 $this->assertEquals([], $linkDB->renameTag('test', ''));
530 $this->assertEquals([], $linkDB->renameTag('test', 'retest'));
531 }
532
533 /**
534 * Test delete tag with a valid value
535 */
536 public function testDeleteTag()
537 {
538 self::$refDB->write(self::$testDatastore);
539 $linkDB = new LinkDB(self::$testDatastore, true, false);
540
541 $res = $linkDB->renameTag('cartoon', null);
542 $this->assertEquals(3, count($res));
543 $this->assertNotContains('cartoon', $linkDB[4]['tags']);
544 }
490} 545}