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,16 +361,26 @@ class Database {
}
public function commit() {
if(!is_null($this->db) && $this->transaction === true) {
$this->transaction = false;
return $this->db->commit();
if(!is_null($this->db)) {
if ($this->transaction === true) {
$this->transaction = false;
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() {
if(!is_null($this->db) && $this->transaction === true) {
$this->transaction = false;
return $this->db->rollback();
if(!is_null($this->db)) {
if ($this->transaction === true) {
$this->transaction = false;
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.");
}
}
}

View file

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