diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/LinkDBTest.php | 55 | ||||
-rw-r--r-- | tests/LinkFilterTest.php | 3 |
2 files changed, 56 insertions, 2 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 | } |
diff --git a/tests/LinkFilterTest.php b/tests/LinkFilterTest.php index 74162358..d796d3a3 100644 --- a/tests/LinkFilterTest.php +++ b/tests/LinkFilterTest.php | |||
@@ -63,10 +63,9 @@ class LinkFilterTest extends PHPUnit_Framework_TestCase | |||
63 | count(self::$linkFilter->filter(LinkFilter::$FILTER_TAG, '')) | 63 | count(self::$linkFilter->filter(LinkFilter::$FILTER_TAG, '')) |
64 | ); | 64 | ); |
65 | 65 | ||
66 | // Untagged only | ||
67 | $this->assertEquals( | 66 | $this->assertEquals( |
68 | self::$refDB->countUntaggedLinks(), | 67 | self::$refDB->countUntaggedLinks(), |
69 | count(self::$linkFilter->filter(LinkFilter::$FILTER_TAG, false)) | 68 | count(self::$linkFilter->filter(LinkFilter::$FILTER_TAG, /*$request=*/'', /*$casesensitive=*/false, /*$visibility=*/'all', /*$untaggedonly=*/true)) |
70 | ); | 69 | ); |
71 | 70 | ||
72 | $this->assertEquals( | 71 | $this->assertEquals( |