MDL-30147 dml - added some tests demoing bad get_columns() behavior

This commit is contained in:
Eloy Lafuente (stronk7)
2011-11-19 09:27:09 +01:00
committed by Petr Skoda
parent 69ac5d478f
commit 8f201c9ded
+22
View File
@@ -821,6 +821,10 @@ class dml_test extends UnitTestCase {
$this->assertEqual($next_column->name, $next_field->name);
}
// Test get_columns for non-existing table returns empty array. MDL-30147
$columns = $DB->get_columns('xxxx');
$this->assertEqual(array(), $columns);
}
public function test_get_manager() {
@@ -1262,6 +1266,24 @@ class dml_test extends UnitTestCase {
$this->assertEqual($e->errorcode, 'textconditionsnotallowed');
}
// test get_records passing non-existing table
try {
$records = $DB->get_records('xxxx', array('id' => 0));
$this->fail('An Exception is missing, expected due to query against non-existing table');
} catch (exception $e) {
$this->assertTrue($e instanceof dml_exception);
$this->assertEqual($e->errorcode, 'ddltablenotexist');
}
// test get_records passing non-existing column
try {
$records = $DB->get_records($tablename, array('xxxx' => 0));
$this->fail('An Exception is missing, expected due to query against non-existing column');
} catch (exception $e) {
$this->assertTrue($e instanceof dml_exception);
$this->assertEqual($e->errorcode, 'ddlfieldnotexist');
}
// note: delegate limits testing to test_get_records_sql()
}