/** * Test adding a new bookmark and delete it * * @return void */ public function testSearch() { // Check it's saved in the DB $bookmarks = WpHerissonBookmarksTable::getSearch('example'); $this->assertEquals(0, sizeof($bookmarks)); // Create a sample bookmark $f = new WpHerissonBookmarks(); $f->url = $this->sampleUrl; $f->save(); $f = new WpHerissonBookmarks(); $f->title = $this->sampleName; $f->save(); $f = new WpHerissonBookmarks(); $f->description = $this->sampleDescription; $f->save(); // Check it's saved in the DB $bookmarks = WpHerissonBookmarksTable::getSearch('example'); $this->assertEquals(3, sizeof($bookmarks)); // Delete it and verify it's not there anymore foreach ($bookmarks as $f) { $f->delete(); } $bookmarks = WpHerissonBookmarksTable::getSearch('example'); $this->assertEquals(0, sizeof($bookmarks)); }
/** * Test adding a new bookmark and delete it * * @return void */ public function testAddBookmarkAndDelete() { // Create a sample bookmark $f = new WpHerissonBookmarks(); $f->setUrl($this->sampleUrl); $f->save(); // Check it's saved in the DB $bookmarks = WpHerissonBookmarksTable::getWhere('url=?', array($this->sampleUrl)); $this->assertEquals(1, sizeof($bookmarks)); // Delete it and verify it's not there anymore foreach ($bookmarks as $f) { $f->delete(); } $bookmarks = WpHerissonBookmarksTable::getWhere('url=?', array($this->sampleUrl)); $this->assertEquals(0, sizeof($bookmarks)); }