]> gitweb.fluxo.info Git - semanticscuttle.git/commitdiff
fix notice when passing an invalid array to editAllowed()
authorcweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>
Thu, 19 Nov 2009 19:22:21 +0000 (19:22 +0000)
committercweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>
Thu, 19 Nov 2009 19:22:21 +0000 (19:22 +0000)
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@558 b3834d28-1941-0410-a4f8-b48e95affb8f

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

index afc4c89928ce7a13932a31369488b8e5d0207d5e..b0ffbac5c36fe2fed8387f28ceb8517cf4cfcb61 100644 (file)
@@ -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;
         }
index 9f02ae60af032f99ea19800cdd86e1f534e2b5da..b99dfd758a65da25fbefed83695d666cb45ea737 100644 (file)
@@ -269,6 +269,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.