The Database class should really throw an error here. This will likely break the existing tests.

This commit is contained in:
jgen 2014-02-22 00:40:14 -05:00
parent 74639cd6b2
commit ba0aef4f30
2 changed files with 17 additions and 6 deletions

View file

@ -361,17 +361,27 @@ class Database {
} }
public function commit() { public function commit() {
if(!is_null($this->db) && $this->transaction === true) { if(!is_null($this->db)) {
if ($this->transaction === true) {
$this->transaction = false; $this->transaction = false;
return $this->db->commit(); return $this->db->commit();
} }
else {
throw new SCoreException("<p><b>Database Transaction Error:</b> Unable to call commit() as there is no transaction currently open.");
}
}
} }
public function rollback() { public function rollback() {
if(!is_null($this->db) && $this->transaction === true) { if(!is_null($this->db)) {
if ($this->transaction === true) {
$this->transaction = false; $this->transaction = false;
return $this->db->rollback(); return $this->db->rollback();
} }
else {
throw new SCoreException("<p><b>Database Transaction Error:</b> Unable to call rollback() as there is no transaction currently open.");
}
}
} }
public function escape($input) { public function escape($input) {

View file

@ -19,6 +19,7 @@ class AliasEditorTest extends ShimmieWebTestCase {
$this->set_field('oldtag', "test1"); $this->set_field('oldtag', "test1");
$this->set_field('newtag', "test2"); $this->set_field('newtag', "test2");
$this->click("Add"); $this->click("Add");
$this->assert_no_text("Error adding alias");
$this->get_page('alias/list'); $this->get_page('alias/list');
$this->assert_text("test1"); $this->assert_text("test1");