test bookmarkExists() in all variations
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@561 b3834d28-1941-0410-a4f8-b48e95affb8f
This commit is contained in:
parent
7a495ede9d
commit
7a9bf6772d
2 changed files with 113 additions and 2 deletions
|
@ -236,10 +236,21 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function bookmarkExists($address = false, $uid = NULL)
|
/**
|
||||||
|
* Checks if a bookmark for the given URL exists
|
||||||
|
* already
|
||||||
|
*
|
||||||
|
* @param string $address URL of bookmark to check
|
||||||
|
* @param integer $uid User id the bookmark has to belong to.
|
||||||
|
* null for all users
|
||||||
|
*
|
||||||
|
* @return boolean True when the bookmark with the given URL
|
||||||
|
* exists for the user, false if not.
|
||||||
|
*/
|
||||||
|
function bookmarkExists($address = false, $uid = null)
|
||||||
{
|
{
|
||||||
if (!$address) {
|
if (!$address) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$address = $this->normalize($address);
|
$address = $this->normalize($address);
|
||||||
|
|
|
@ -134,6 +134,106 @@ class BookmarkTest extends TestBase
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests if bookmarkExists() returns false when the given
|
||||||
|
* parameter is invalid.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testBookmarkExistsInvalidParam()
|
||||||
|
{
|
||||||
|
$this->assertFalse($this->bs->bookmarkExists(false));
|
||||||
|
$this->assertFalse($this->bs->bookmarkExists(null));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests if bookmarkExists() returns true when a bookmark
|
||||||
|
* exists
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testBookmarkExistsTrue()
|
||||||
|
{
|
||||||
|
$bid = $this->addBookmark();
|
||||||
|
$bookmark = $this->bs->getBookmark($bid);
|
||||||
|
|
||||||
|
$this->assertTrue($this->bs->bookmarkExists($bookmark['bAddress']));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests if bookmarkExists() returns false when a bookmark
|
||||||
|
* does not exist
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testBookmarkExistsFalse()
|
||||||
|
{
|
||||||
|
$this->assertFalse($this->bs->bookmarkExists('does-not-exist'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests if bookmarkExists() returns true when a bookmark
|
||||||
|
* exists for a user
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testBookmarkExistsUserTrue()
|
||||||
|
{
|
||||||
|
$bid = $this->addBookmark();
|
||||||
|
$bookmark = $this->bs->getBookmark($bid);
|
||||||
|
|
||||||
|
$this->assertTrue(
|
||||||
|
$this->bs->bookmarkExists(
|
||||||
|
$bookmark['bAddress'],
|
||||||
|
$bookmark['uId']
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests if bookmarkExists() returns false when a bookmark
|
||||||
|
* does not exist for a user
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testBookmarkExistsUserFalse()
|
||||||
|
{
|
||||||
|
$this->assertFalse(
|
||||||
|
$this->bs->bookmarkExists('does-not-exist', 1234)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests if bookmarkExists() returns false when a bookmark
|
||||||
|
* does not exist for a user but for another user
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testBookmarkExistsOtherUser()
|
||||||
|
{
|
||||||
|
$bid = $this->addBookmark();
|
||||||
|
$bookmark = $this->bs->getBookmark($bid);
|
||||||
|
|
||||||
|
$this->assertFalse(
|
||||||
|
$this->bs->bookmarkExists(
|
||||||
|
$bookmark['bAddress'],
|
||||||
|
$bookmark['uId'] + 1
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test if countBookmarks() works with no bookmarks
|
* Test if countBookmarks() works with no bookmarks
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue