Пример #1
0
 public function testTotal()
 {
     $this->object->insert(new Author(array('name' => "Franta Skočdopole", 'web' => "http://example.com/")));
     $id = dibi::getInsertId();
     $this->assertEquals((array) dibi::select("*")->from("authors")->where("[id] = %i", $id)->execute()->fetch(), array('id' => $id, 'name' => "Franta Skočdopole", 'web' => "http://example.com/"));
     $this->assertEquals($id, $this->object->lastPrimaryKey());
     $author = new Author(array('id' => $id, 'name' => "Franta Vomáčka", 'web' => "http://example.com/"));
     $this->object->update($author);
     $this->assertEquals((array) dibi::select("*")->from("authors")->where("[id] = %i", $id)->execute()->fetch(), array('id' => $id, 'name' => "Franta Vomáčka", 'web' => "http://example.com/"));
     $this->object->delete($author);
     $this->assertFalse(dibi::select("*")->from("authors")->where("[id] = %i", $id)->execute()->fetch());
 }