MDL-37854 phpunit: replaced occurrence of non-existent function assertFail

This commit is contained in:
Mark Nelson 2013-02-05 11:57:03 +08:00
parent 913084399a
commit 9efe2ca244
2 changed files with 19 additions and 19 deletions

View file

@ -1797,7 +1797,7 @@ class dml_testcase extends database_driver_testcase {
$this->assertSame(false, $DB->get_field($tablename, 'course', array('course' => 11), IGNORE_MISSING)); $this->assertSame(false, $DB->get_field($tablename, 'course', array('course' => 11), IGNORE_MISSING));
try { try {
$DB->get_field($tablename, 'course', array('course' => 4), MUST_EXIST); $DB->get_field($tablename, 'course', array('course' => 4), MUST_EXIST);
$this->assertFail('Exception expected due to missing record'); $this->fail('Exception expected due to missing record');
} catch (dml_exception $ex) { } catch (dml_exception $ex) {
$this->assertTrue(true); $this->assertTrue(true);
} }
@ -1952,7 +1952,7 @@ class dml_testcase extends database_driver_testcase {
// custom sequence - missing id error // custom sequence - missing id error
try { try {
$DB->insert_record_raw($tablename, array('course' => 3, 'onechar' => 'bb'), true, false, true); $DB->insert_record_raw($tablename, array('course' => 3, 'onechar' => 'bb'), true, false, true);
$this->assertFail('Exception expected due to missing record'); $this->fail('Exception expected due to missing record');
} catch (coding_exception $ex) { } catch (coding_exception $ex) {
$this->assertTrue(true); $this->assertTrue(true);
} }
@ -1960,7 +1960,7 @@ class dml_testcase extends database_driver_testcase {
// wrong column error // wrong column error
try { try {
$DB->insert_record_raw($tablename, array('xxxxx' => 3, 'onechar' => 'bb')); $DB->insert_record_raw($tablename, array('xxxxx' => 3, 'onechar' => 'bb'));
$this->assertFail('Exception expected due to invalid column'); $this->fail('Exception expected due to invalid column');
} catch (dml_exception $ex) { } catch (dml_exception $ex) {
$this->assertTrue(true); $this->assertTrue(true);
} }

View file

@ -1405,46 +1405,46 @@ class moodlelib_testcase extends advanced_testcase {
$longvalue = str_repeat('a', 1334); $longvalue = str_repeat('a', 1334);
try { try {
set_user_preference('_test_long_user_preference', $longvalue); set_user_preference('_test_long_user_preference', $longvalue);
$this->assertFail('Exception expected - longer than 1333 chars not allowed as preference value'); $this->fail('Exception expected - longer than 1333 chars not allowed as preference value');
} catch (Exception $e) { } catch (coding_exception $ex) {
$this->assertTrue($e instanceof coding_exception); $this->assertTrue(true);
} }
//test invalid params //test invalid params
try { try {
set_user_preference('_test_user_preferences_pref', array()); set_user_preference('_test_user_preferences_pref', array());
$this->assertFail('Exception expected - array not valid preference value'); $this->fail('Exception expected - array not valid preference value');
} catch (Exception $ex) { } catch (coding_exception $ex) {
$this->assertTrue(true); $this->assertTrue(true);
} }
try { try {
set_user_preference('_test_user_preferences_pref', new stdClass); set_user_preference('_test_user_preferences_pref', new stdClass);
$this->assertFail('Exception expected - class not valid preference value'); $this->fail('Exception expected - class not valid preference value');
} catch (Exception $ex) { } catch (coding_exception $ex) {
$this->assertTrue(true); $this->assertTrue(true);
} }
try { try {
set_user_preference('_test_user_preferences_pref', 1, array('xx'=>1)); set_user_preference('_test_user_preferences_pref', 1, array('xx' => 1));
$this->assertFail('Exception expected - user instance expected'); $this->fail('Exception expected - user instance expected');
} catch (Exception $ex) { } catch (coding_exception $ex) {
$this->assertTrue(true); $this->assertTrue(true);
} }
try { try {
set_user_preference('_test_user_preferences_pref', 1, 'abc'); set_user_preference('_test_user_preferences_pref', 1, 'abc');
$this->assertFail('Exception expected - user instance expected'); $this->fail('Exception expected - user instance expected');
} catch (Exception $ex) { } catch (coding_exception $ex) {
$this->assertTrue(true); $this->assertTrue(true);
} }
try { try {
set_user_preference('', 1); set_user_preference('', 1);
$this->assertFail('Exception expected - invalid name accepted'); $this->fail('Exception expected - invalid name accepted');
} catch (Exception $ex) { } catch (coding_exception $ex) {
$this->assertTrue(true); $this->assertTrue(true);
} }
try { try {
set_user_preference('1', 1); set_user_preference('1', 1);
$this->assertFail('Exception expected - invalid name accepted'); $this->fail('Exception expected - invalid name accepted');
} catch (Exception $ex) { } catch (coding_exception $ex) {
$this->assertTrue(true); $this->assertTrue(true);
} }