/** * Action to display a bookmark content * * @return void */ function viewAction() { $id = intval(get('id')); if (!$id) { echo __("Error : Missing id\n", HERISSON_TD); exit; } $bookmark = WpHerissonBookmarksTable::get($id); if ($bookmark && $bookmark->content) { echo $bookmark->content; } else { echo sprintf(__("Error : Missing content for bookmark %s\n", HERISSON_TD), $bookmark->id); } exit; }
/** * Test getting an null object * * @return void */ public function testGetNull() { $f = WpHerissonBookmarksTable::get(null); $this->assertEquals(get_class($f), 'Herisson\\Model\\WpHerissonBookmarks'); $this->assertEmpty($f->url); $this->assertEmpty($f->title); $this->assertEmpty($f->description); $f = WpHerissonBookmarksTable::get(123456789); $this->assertEquals(get_class($f), 'Herisson\\Model\\WpHerissonBookmarks'); $this->assertEmpty($f->url); $this->assertEmpty($f->title); $this->assertEmpty($f->description); }
/** * Test setting and retrieving data * * @return void */ public function testCreateSaveAndRetrieve() { $datas = $this->fakeFields; $b = $this->_getBookmark($datas); $sql = array(); foreach ($datas as $key => $value) { $sql[] = "{$key}=?"; } // Check it's saved in the DB, with all parameters $bookmarks = WpHerissonBookmarksTable::getWhere(implode(' AND ', $sql), array_values($datas)); $this->assertEquals(1, sizeof($bookmarks)); // Retrieve the id $g = WpHerissonBookmarksTable::get($b->id); foreach ($datas as $key => $value) { $this->assertEquals($value, $g->{$key}); } // Cleanup $g->delete(); }