public function update()
 {
     if (isset($_REQUEST['bookmark_id'])) {
         try {
             $bookmark = new Bookmark($_REQUEST['bookmark_id']);
         } catch (\Exception $e) {
             $_SESSION['errorMessages'][] = $e;
             header('Location: ' . BASE_URL . '/bookmarks');
             exit;
         }
     } else {
         $bookmark = new Bookmark();
     }
     if (isset($_POST['requestUri'])) {
         $bookmark->handleUpdate($_POST);
         try {
             $bookmark->save();
             // Bookmarks are always created in place.
             // So, the Uri for the bookmark is the same Uri to
             // go back to the previous screen.
             header('Location: ' . $bookmark->getFullUrl());
             exit;
         } catch (\Exception $e) {
             $_SESSION['errorMessages'][] = $e;
         }
     }
     $this->template->blocks[] = new Block('bookmarks/updateForm.inc', array('bookmark' => $bookmark));
 }
 public function testSaveAndLoad()
 {
     $_SESSION['USER'] = new Person($this->testPersonId);
     $bookmark = new Bookmark();
     $bookmark->setRequestUri('/test');
     $bookmark->save();
     $id = $bookmark->getId();
     $this->assertNotEmpty($id);
     $bookmark = new Bookmark($id);
     $this->assertEquals($this->testPersonId, $bookmark->getPerson_id());
     $this->assertEquals('/test', $bookmark->getRequestUri());
 }