Exemple #1
0
 public function test_save()
 {
     $test = new Test();
     $test->name = 'inserted from phpunit';
     $test->save();
     $id = $test->id;
     $this->assertNotEmpty($id, "save should save the model to the db and update the auto_increment column");
     $this->assertFalse($test->save(), "saving a clean db model should return false");
     $test->name .= $test->name;
     $test->set_literal('dateTimeAdded', 'NOW()');
     $test->save();
     $this->assertEquals($test->name, Test::fetch_by_id($id)->name, "saving an existing db model should do an update");
     $test->delete();
 }
 public function test_get_sql_history()
 {
     $this->assertEquals([], $this->connection->get_sql_history(), "sql history should be empty if logging is disabled");
     Generic::$connection->set_logging_enabled(true);
     \DB\Scoop\Test::fetch_by_id(1);
     $this->assertNotEmpty(Generic::$connection->get_sql_history(), "sql history should not be empty after enabling logging and running a query");
     Generic::$connection->set_logging_enabled(false);
 }