NOBUG: Added some tests with empty strings in insert_record/update_record/set_field

that reveal inconsistencies between DBs
This commit is contained in:
Eloy Lafuente 2009-11-03 18:11:18 +00:00
parent 86449d2214
commit fdc45ac360

View File

@ -1239,6 +1239,24 @@ class dml_test extends UnitTestCase {
$this->assertTrue($e instanceof dml_exception);
}
// Check empty string data causes exception in numeric types
$record->oneint = ''; // empty string
$record->onenum = 0;
try {
$DB->insert_record($tablename, $record);
$this->fail("Expecting an exception, none occurred");
} catch (exception $e) {
$this->assertTrue($e instanceof dml_exception);
}
$record->oneint = 0;
$record->onenum = ''; // empty string
try {
$DB->insert_record($tablename, $record);
$this->fail("Expecting an exception, none occurred");
} catch (exception $e) {
$this->assertTrue($e instanceof dml_exception);
}
// Check empty strings are set properly in string types
$record->oneint = 0;
$record->onenum = 0;
@ -1450,6 +1468,24 @@ class dml_test extends UnitTestCase {
$this->assertTrue($e instanceof dml_exception);
}
// Check empty string data causes exception in numeric types
$record->oneint = ''; // empty string
$record->onenum = 0;
try {
$DB->update_record($tablename, $record);
$this->fail("Expecting an exception, none occurred");
} catch (exception $e) {
$this->assertTrue($e instanceof dml_exception);
}
$record->oneint = 0;
$record->onenum = ''; // empty string
try {
$DB->update_record($tablename, $record);
$this->fail("Expecting an exception, none occurred");
} catch (exception $e) {
$this->assertTrue($e instanceof dml_exception);
}
// Check empty strings are set properly in string types
$record->oneint = 0;
$record->onenum = 0;
@ -1606,6 +1642,20 @@ class dml_test extends UnitTestCase {
$this->assertTrue($e instanceof dml_exception);
}
// Check empty string data causes exception in numeric types
try {
$DB->set_field_select($tablename, 'oneint', '', 'id = ?', array(1));
$this->fail("Expecting an exception, none occurred");
} catch (exception $e) {
$this->assertTrue($e instanceof dml_exception);
}
try {
$DB->set_field_select($tablename, 'onenum', '', 'id = ?', array(1));
$this->fail("Expecting an exception, none occurred");
} catch (exception $e) {
$this->assertTrue($e instanceof dml_exception);
}
// Check empty strings are set properly in string types
$DB->set_field_select($tablename, 'onechar', '', 'id = ?', array(1));
$DB->set_field_select($tablename, 'onetext', '', 'id = ?', array(1));