MDL-30147 do not expect text comparison exceptions when not in debug mode

Unfortunately the column type fetching is too expensive, we do extra verification in debug mode only.
This commit is contained in:
Petr Skoda 2011-11-19 09:43:09 +01:00
parent a453ec079f
commit fed02be153

View file

@ -1003,7 +1003,10 @@ class dml_test extends UnitTestCase {
$conditions = array('onetext' => '1'); $conditions = array('onetext' => '1');
try { try {
$rs = $DB->get_recordset($tablename, $conditions); $rs = $DB->get_recordset($tablename, $conditions);
$this->fail('An Exception is missing, expected due to equating of text fields'); if (debugging()) {
// only in debug mode - hopefully all devs test code in debug mode...
$this->fail('An Exception is missing, expected due to equating of text fields');
}
} catch (exception $e) { } catch (exception $e) {
$this->assertTrue($e instanceof dml_exception); $this->assertTrue($e instanceof dml_exception);
$this->assertEqual($e->errorcode, 'textconditionsnotallowed'); $this->assertEqual($e->errorcode, 'textconditionsnotallowed');
@ -1260,7 +1263,10 @@ class dml_test extends UnitTestCase {
$conditions = array('onetext' => '1'); $conditions = array('onetext' => '1');
try { try {
$records = $DB->get_records($tablename, $conditions); $records = $DB->get_records($tablename, $conditions);
$this->fail('An Exception is missing, expected due to equating of text fields'); if (debugging()) {
// only in debug mode - hopefully all devs test code in debug mode...
$this->fail('An Exception is missing, expected due to equating of text fields');
}
} catch (exception $e) { } catch (exception $e) {
$this->assertTrue($e instanceof dml_exception); $this->assertTrue($e instanceof dml_exception);
$this->assertEqual($e->errorcode, 'textconditionsnotallowed'); $this->assertEqual($e->errorcode, 'textconditionsnotallowed');
@ -1681,7 +1687,10 @@ class dml_test extends UnitTestCase {
$conditions = array('onetext' => '1'); $conditions = array('onetext' => '1');
try { try {
$DB->get_field($tablename, 'course', $conditions); $DB->get_field($tablename, 'course', $conditions);
$this->fail('An Exception is missing, expected due to equating of text fields'); if (debugging()) {
// only in debug mode - hopefully all devs test code in debug mode...
$this->fail('An Exception is missing, expected due to equating of text fields');
}
} catch (exception $e) { } catch (exception $e) {
$this->assertTrue($e instanceof dml_exception); $this->assertTrue($e instanceof dml_exception);
$this->assertEqual($e->errorcode, 'textconditionsnotallowed'); $this->assertEqual($e->errorcode, 'textconditionsnotallowed');
@ -2534,7 +2543,10 @@ class dml_test extends UnitTestCase {
$conditions = array('onetext' => '1'); $conditions = array('onetext' => '1');
try { try {
$DB->set_field($tablename, 'onechar', 'frog', $conditions); $DB->set_field($tablename, 'onechar', 'frog', $conditions);
$this->fail('An Exception is missing, expected due to equating of text fields'); if (debugging()) {
// only in debug mode - hopefully all devs test code in debug mode...
$this->fail('An Exception is missing, expected due to equating of text fields');
}
} catch (exception $e) { } catch (exception $e) {
$this->assertTrue($e instanceof dml_exception); $this->assertTrue($e instanceof dml_exception);
$this->assertEqual($e->errorcode, 'textconditionsnotallowed'); $this->assertEqual($e->errorcode, 'textconditionsnotallowed');
@ -2744,7 +2756,10 @@ class dml_test extends UnitTestCase {
$conditions = array('onetext' => '1'); $conditions = array('onetext' => '1');
try { try {
$DB->count_records($tablename, $conditions); $DB->count_records($tablename, $conditions);
$this->fail('An Exception is missing, expected due to equating of text fields'); if (debugging()) {
// only in debug mode - hopefully all devs test code in debug mode...
$this->fail('An Exception is missing, expected due to equating of text fields');
}
} catch (exception $e) { } catch (exception $e) {
$this->assertTrue($e instanceof dml_exception); $this->assertTrue($e instanceof dml_exception);
$this->assertEqual($e->errorcode, 'textconditionsnotallowed'); $this->assertEqual($e->errorcode, 'textconditionsnotallowed');
@ -2819,7 +2834,10 @@ class dml_test extends UnitTestCase {
$conditions = array('onetext' => '1'); $conditions = array('onetext' => '1');
try { try {
$DB->record_exists($tablename, $conditions); $DB->record_exists($tablename, $conditions);
$this->fail('An Exception is missing, expected due to equating of text fields'); if (debugging()) {
// only in debug mode - hopefully all devs test code in debug mode...
$this->fail('An Exception is missing, expected due to equating of text fields');
}
} catch (exception $e) { } catch (exception $e) {
$this->assertTrue($e instanceof dml_exception); $this->assertTrue($e instanceof dml_exception);
$this->assertEqual($e->errorcode, 'textconditionsnotallowed'); $this->assertEqual($e->errorcode, 'textconditionsnotallowed');
@ -2967,7 +2985,10 @@ class dml_test extends UnitTestCase {
$conditions = array('onetext'=>'1'); $conditions = array('onetext'=>'1');
try { try {
$DB->delete_records($tablename, $conditions); $DB->delete_records($tablename, $conditions);
$this->fail('An Exception is missing, expected due to equating of text fields'); if (debugging()) {
// only in debug mode - hopefully all devs test code in debug mode...
$this->fail('An Exception is missing, expected due to equating of text fields');
}
} catch (exception $e) { } catch (exception $e) {
$this->assertTrue($e instanceof dml_exception); $this->assertTrue($e instanceof dml_exception);
$this->assertEqual($e->errorcode, 'textconditionsnotallowed'); $this->assertEqual($e->errorcode, 'textconditionsnotallowed');
@ -2977,7 +2998,10 @@ class dml_test extends UnitTestCase {
$conditions = array('onetext' => 1); $conditions = array('onetext' => 1);
try { try {
$DB->delete_records($tablename, $conditions); $DB->delete_records($tablename, $conditions);
$this->fail('An Exception is missing, expected due to equating of text fields'); if (debugging()) {
// only in debug mode - hopefully all devs test code in debug mode...
$this->fail('An Exception is missing, expected due to equating of text fields');
}
} catch (exception $e) { } catch (exception $e) {
$this->assertTrue($e instanceof dml_exception); $this->assertTrue($e instanceof dml_exception);
$this->assertEqual($e->errorcode, 'textconditionsnotallowed'); $this->assertEqual($e->errorcode, 'textconditionsnotallowed');