function testAfterDelete() { Model3::addEvent('after_delete', array($this, 'on_delete')); $m3 = new Model3(); $m3->a = ''; $m3->int = rand(); $m3->save(); $id = (string) $m3->getId(); $m3->delete(); $this->assertEquals($id, $this->deleted); }
function testDelete() { /* Delete using a criteria */ $c = new Model3(); $c->where('int < ', 100); $c->delete(); $this->assertEquals($c->count(), 4900); /* delete on iteration (element by element) */ $c = new Model3(); $c->where('int', array(200, 300)); $i = 0; foreach ($c as $d) { $d->delete(); $this->assertFalse(isset($c->int)); $i++; } $c->reset(); $this->assertEquals(2, $i); $this->assertEquals($c->count(), 4898); }