public function testDelete() { $db = $this->getDb(); $table = new SqlTable($db, 'Foo'); $selection = new SelectionBuilder($table); // Update all $db->expects($this->exactly(3))->method('execute')->withConsecutive([$this->equalTo('DELETE FROM {Foo}')], [$this->equalTo('DELETE FROM {Foo} WHERE group = "user" ORDER BY name DESC')], [$this->equalTo('DELETE FROM {Foo} LIMIT 10')])->willReturn(0); $selection->delete(); // Update with predicate and ordering $selection->where('group = "user"')->orderByDescending('name')->delete(); // Update with limit $selection->limit(10)->delete(); }
/** * Limit number of records. * * @param * int Number of records. * @return SelectionBuilder A selection. */ public function limit($limit) { $selection = new SelectionBuilder($this->getSource()); return $selection->limit($limit); }