/** * Handle the validation of bookmarks to import after the user choose which bookmarks he wants to import * * @return void */ function importValidateAction() { $bookmarks = post('bookmarks'); $nb = 0; foreach ($bookmarks as $bookmark) { if (array_key_exists('import', $bookmark) && $bookmark['import']) { $nb++; $tags = array_key_exists('tags', $bookmark) ? explode(",", $bookmark['tags']) : array(); /* if (!strlen($bookmark['url'])) { print_r($bookmark); } */ try { WpHerissonBookmarks::createBookmark($bookmark); } catch (\Herisson\Model\Exception $e) { Message::i()->addError($e->getMessage()); continue; } } } Message::i()->addSucces(sprintf(__("Successfully add %s bookmarks !", HERISSON_TD), $nb)); $this->indexAction(); $this->setView('index'); }
/** * Test createBookmark static method, and verify url is mandatory * * @return void */ public function testCreateBookmarkMissingUrl() { $data = array('title' => $this->sampleName, 'content' => $this->sampleDescription); $this->setExpectedException("Herisson\\Model\\Exception"); $id = WpHerissonBookmarks::createBookmark($data); }