diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Bookmark2TagTest.php | 45 | ||||
-rwxr-xr-x | tests/www/bookmarksTest.php | 28 |
2 files changed, 73 insertions, 0 deletions
diff --git a/tests/Bookmark2TagTest.php b/tests/Bookmark2TagTest.php index 0236a5f..f466a7d 100644 --- a/tests/Bookmark2TagTest.php +++ b/tests/Bookmark2TagTest.php @@ -71,6 +71,26 @@ class Bookmark2TagTest extends TestBase + public function testAttachTagsWithoutTagsAddsSystemUnfiled() + { + $bid = $this->addBookmark(null, null, 0, array()); + $this->assertEquals( + array('system:unfiled'), + $this->b2ts->getTagsForBookmark($bid, true) + ); + } + + public function testAttachTagsWithArrayWithEmptyStringAddsSystemUnfiled() + { + $bid = $this->addBookmark(null, null, 0, array('')); + $this->assertEquals( + array('system:unfiled'), + $this->b2ts->getTagsForBookmark($bid, true) + ); + } + + + /** * Test getTagsForBookmark() when the bookmark has no tags * @@ -500,6 +520,31 @@ class Bookmark2TagTest extends TestBase $this->assertContains(array('tag' => 'thr', 'bCount' => '1'), $arTags); } + /** + * Should return the logged on user's public, protected and private tags + * as well as public ones of other specified users. + * + * @covers SemanticScuttle_Service_Bookmark2Tag::getPopularTags + */ + public function testGetPopularTagsUserPrivatesAndOthersWhenLoggedIn() + { + $user1 = $this->addUser(); + $user2 = $this->addUser(); + $this->addBookmark($user1, null, 0, array('one')); + $this->addBookmark($user1, null, 1, array('one', 'two')); + $this->addBookmark($user1, null, 2, array('thr')); + $this->addBookmark($user2, null, 0, array('fou')); + $this->addBookmark($user2, null, 1, array('fiv')); + $this->addBookmark($user2, null, 2, array('six')); + + $arTags = $this->b2ts->getPopularTags(array($user2, $user1), 10, $user1); + $this->assertContains(array('tag' => 'one', 'bCount' => '2'), $arTags); + $this->assertContains(array('tag' => 'two', 'bCount' => '1'), $arTags); + $this->assertContains(array('tag' => 'thr', 'bCount' => '1'), $arTags); + $this->assertContains(array('tag' => 'fou', 'bCount' => '1'), $arTags); + $this->assertEquals(4, count($arTags)); + } + /** * @covers SemanticScuttle_Service_Bookmark2Tag::getAdminTags diff --git a/tests/www/bookmarksTest.php b/tests/www/bookmarksTest.php index ae82118..ac549d8 100755 --- a/tests/www/bookmarksTest.php +++ b/tests/www/bookmarksTest.php @@ -124,5 +124,33 @@ class www_bookmarksTest extends TestBaseApi $this->assertNotContains('privateKey=', (string)$elements[0]['href']); }//end testVerifyPrivateRSSLinkDoesNotExist + + + /** + * We once had the bug that URLs with special characters were escaped too + * often. & -> & + */ + public function testAddressEncoding() + { + $this->addBookmark(null, 'http://example.org?foo&bar=baz'); + + //get rid of bookmarks.php + $this->url = $GLOBALS['unittestUrl']; + + $html = $this->getRequest()->send()->getBody(); + $x = simplexml_load_string($html); + $ns = $x->getDocNamespaces(); + $x->registerXPathNamespace('ns', reset($ns)); + + $elements = $x->xpath('//ns:a[@class="taggedlink"]'); + $this->assertEquals( + 1, count($elements), 'Number of links is not 1' + ); + $this->assertEquals( + 'http://example.org?foo&bar=baz', + (string)$elements[0]['href'] + ); + } + }//end class www_bookmarksTest ?> |