aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/SemanticScuttle/Service/Bookmark.php7
-rw-r--r--tests/BookmarkTest.php54
2 files changed, 59 insertions, 2 deletions
diff --git a/src/SemanticScuttle/Service/Bookmark.php b/src/SemanticScuttle/Service/Bookmark.php
index afc4c89..b0ffbac 100644
--- a/src/SemanticScuttle/Service/Bookmark.php
+++ b/src/SemanticScuttle/Service/Bookmark.php
@@ -206,8 +206,11 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
*/
function editAllowed($bookmark)
{
- if (!is_numeric($bookmark) && (!is_array($bookmark)
- || !is_numeric($bookmark['bId']))
+ if (!is_numeric($bookmark)
+ && (!is_array($bookmark)
+ || !isset($bookmark['bId'])
+ || !is_numeric($bookmark['bId'])
+ )
) {
return false;
}
diff --git a/tests/BookmarkTest.php b/tests/BookmarkTest.php
index 9f02ae6..b99dfd7 100644
--- a/tests/BookmarkTest.php
+++ b/tests/BookmarkTest.php
@@ -270,6 +270,60 @@ class BookmarkTest extends TestBase
/**
+ * Test if editAllowed() returns false when the bookmark
+ * id is invalid.
+ *
+ * @return void
+ */
+ public function testEditAllowedInvalidBookmarkId()
+ {
+ $this->assertFalse($this->bs->editAllowed('invalid'));
+ $this->assertFalse($this->bs->editAllowed(array()));
+ $this->assertFalse($this->bs->editAllowed(array('some', 'where')));
+ $this->assertFalse($this->bs->editAllowed(array('bId' => false)));
+ $this->assertFalse($this->bs->editAllowed(array('bId' => 'foo')));
+ }
+
+
+
+ /**
+ * Test if editAllowed() works when passing the ID of
+ * an existing bookmark.
+ *
+ * @return void
+ */
+ public function testEditAllowedBookmarkId()
+ {
+ }
+
+
+
+ /**
+ * Test if editAllowed() works when passing a bookmark
+ * row.
+ *
+ * @return void
+ */
+ public function testEditAllowedBookmarkRow()
+ {
+ }
+
+
+
+ /**
+ * Test if editAllowed() returns false when the bookmark
+ * specified by the ID does not exist.
+ *
+ * @return void
+ */
+ public function testEditAllowedIdNotFound()
+ {
+ $this->assertFalse($this->bs->editAllowed(98765));
+ }
+
+
+
+ /**
* Verify that getBookmark() returns false when the
* bookmark cannot be found.
*