]> gitweb.fluxo.info Git - semanticscuttle.git/commitdiff
test deleteBookmarksForUser
authorcweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>
Fri, 20 Nov 2009 17:38:15 +0000 (17:38 +0000)
committercweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>
Fri, 20 Nov 2009 17:38:15 +0000 (17:38 +0000)
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@565 b3834d28-1941-0410-a4f8-b48e95affb8f

src/SemanticScuttle/Service/Bookmark.php
tests/BookmarkTest.php

index 1975b22a539a1c1f25ed5a4f2e7f5706a6e7b02d..f671fbaf4036c385cdd32882aef38c6fed628c76 100644 (file)
@@ -778,6 +778,13 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
 
 
 
+    /**
+     * Deletes all bookmarks of the given user
+     *
+     * @param integer $uId User ID
+     *
+     * @return boolean true when all went well
+     */
     public function deleteBookmarksForUser($uId)
     {
         $query = 'DELETE FROM '. $GLOBALS['tableprefix'] .'bookmarks WHERE uId = '. intval($uId);
index f7d8ead58fe972ebfbe97ab2adef47a32f267252..0b47bc265659de7b862473092631e86e258c6a20 100644 (file)
@@ -342,6 +342,59 @@ class BookmarkTest extends TestBase
 
 
 
+    /**
+     * Test if deleting all bookmarks for a user works.
+     *
+     * @return void
+     */
+    public function testDeleteBookmarksForUser()
+    {
+        $uid = $this->addUser();
+        $bookmarks = $this->bs->getBookmarks(0, null, $uid);
+        $this->assertEquals(0, $bookmarks['total']);
+
+        $this->addBookmark($uid);
+        $this->addBookmark($uid);
+        $bookmarks = $this->bs->getBookmarks(0, null, $uid);
+        $this->assertEquals(2, $bookmarks['total']);
+
+        $this->bs->deleteBookmarksForUser($uid);
+        $bookmarks = $this->bs->getBookmarks(0, null, $uid);
+        $this->assertEquals(0, $bookmarks['total']);
+    }
+
+
+
+    /**
+     * Test if deleting all bookmarks for a user works
+     * and does not damage other user's bookmarks.
+     *
+     * @return void
+     */
+    public function testDeleteBookmarksForUserOthers()
+    {
+        $uidOther = $this->addUser();
+        $this->addBookmark($uidOther);
+
+        $uid = $this->addUser();
+        $bookmarks = $this->bs->getBookmarks(0, null, $uid);
+        $this->assertEquals(0, $bookmarks['total']);
+
+        $this->addBookmark($uid);
+        $this->addBookmark($uid);
+        $bookmarks = $this->bs->getBookmarks(0, null, $uid);
+        $this->assertEquals(2, $bookmarks['total']);
+
+        $this->bs->deleteBookmarksForUser($uid);
+        $bookmarks = $this->bs->getBookmarks(0, null, $uid);
+        $this->assertEquals(0, $bookmarks['total']);
+
+        $bookmarks = $this->bs->getBookmarks(0, null, $uidOther);
+        $this->assertEquals(1, $bookmarks['total']);
+    }
+
+
+
     /**
      * Test if deleting a bookmark with a vote works.
      *