public function testDelete() { // Look up the SIDS // Ok, we cant really test this, so we use implementation knowledge $q = DB::prepare('SELECT SID FROM SearchFooIndex WHERE title=:title AND someOtherPrimary=:primary'); $q->execute(array(':title' => 'My Title', ':primary' => 'other-primary')); $SIDS = $q->fetchAll(); $someFoo = SearchFoo::get('My Title', 'other-primary', '2010-01-01'); $someFoo->delete(); // See if it is completely removed // Ok, we cant really test this, so we use implementation knowledge $q = DB::prepare('SELECT * FROM SearchFooIndex WHERE title=:title AND someOtherPrimary=:primary'); $q->execute(array(':title' => 'My Title', ':primary' => 'other-primary')); $this->assertFalse($q->fetch()); $q = DB::prepare('SELECT * FROM SearchIndex WHERE SID=:SID'); $q->execute(array(':SID' => $SIDS[0]['SID'])); $this->assertFalse($q->fetch()); $pager = SearchFoo::search('rainbow', 'en'); $results = $pager->execute(1, 10); $this->assertEquals(0, count($results)); $someFoo = new SearchFoo; $someFoo->title = 'My Title'; $someFoo->someOtherPrimary = 'other-primary'; $someFoo->datePrimary = '2010-01-01'; $someFoo->body = 'Empty body'; $someFoo->language = 'en'; $someFoo->save(); $pager = SearchFoo::search('body', 'en'); $results = $pager->execute(1, 10); $this->assertEquals(1, count($results)); }