From: skodak Date: Sat, 10 Jan 2009 13:47:26 +0000 (+0000) Subject: MDL-16483 - renamed MoodleUnitTestCase to FakeDBUnitTestCase; MDL-17841 removed bogus... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=58fa5d6f75be93925034fc9e840d8ed0acdbd5c9;p=moodle.git MDL-16483 - renamed MoodleUnitTestCase to FakeDBUnitTestCase; MDL-17841 removed bogus remove lib/simpletest/slowcodetest.php --- diff --git a/grade/simpletest/testreportlib.php b/grade/simpletest/testreportlib.php index 6d9df6e85e..69eed7d41b 100644 --- a/grade/simpletest/testreportlib.php +++ b/grade/simpletest/testreportlib.php @@ -40,7 +40,7 @@ require_once($CFG->dirroot.'/grade/report/lib.php'); /** * @TODO create a set of mock objects to simulate the database operations. We don't want to connect to any real sql server. */ -class gradereportlib_test extends MoodleUnitTestCase { +class gradereportlib_test extends FakeDBUnitTestCase { var $courseid = 1; var $context = null; var $report = null; diff --git a/lib/simpletest/fixtures/gradetest.php b/lib/simpletest/fixtures/gradetest.php index e329dcab31..259efb67d8 100644 --- a/lib/simpletest/fixtures/gradetest.php +++ b/lib/simpletest/fixtures/gradetest.php @@ -49,7 +49,7 @@ Mock::generate('grade_outcome', 'mock_grade_outcome'); * category1 => array(category2 => array(grade_item1, grade_item2), category3 => array(grade_item3)) * 3 users for 3 grade_items */ -class grade_test extends MoodleUnitTestCase { +class grade_test extends FakeDBUnitTestCase { public $grade_tables = array('grade_categories', 'scale', diff --git a/lib/simpletest/portfolio_testclass.php b/lib/simpletest/portfolio_testclass.php index c0dc3460d2..d101f0a61b 100644 --- a/lib/simpletest/portfolio_testclass.php +++ b/lib/simpletest/portfolio_testclass.php @@ -184,7 +184,7 @@ foreach ($portfolio_plugins as $plugin) { Mock::generatePartial("portfolio_plugin_$plugin", "partialmock_plugin_$plugin", array('send_package')); } -class portfoliolib_test extends MoodleUnitTestCase { +class portfoliolib_test extends FakeDBUnitTestCase { function setup() { parent::setup(); diff --git a/lib/simpletest/slowtestcode.php b/lib/simpletest/slowtestcode.php deleted file mode 100644 index d353853a04..0000000000 --- a/lib/simpletest/slowtestcode.php +++ /dev/null @@ -1,58 +0,0 @@ -dirroot . $string; - } - - function test_php_syntax() { - global $CFG; - - // See if we can run php from the command line: - $this->phppath = 'php'; - if (!shell_exec($this->phppath . ' -v')) { - // If not, we can't do anything. - $this->fail('Cannot test PHP syntax because PHP is not on the path.'); - return; - } - - $regexp = '/\.(' . implode('|', $this->php_code_extensions) . ')$/'; - $ignore = array_map(array($this, 'prepend_dirroot'), $this->ignore_folders); - recurseFolders($CFG->dirroot, array($this, 'syntax_check_file'), $regexp, false, $ignore); - } - - var $dotcount = 0; - function syntax_check_file($filepath) { - // If you don't print something for each test, then for some reason the - // server hangs after a thousand files or so. It is very intermittent. - // Printing a space does not seem to be good enough. - echo '.'; - if (++$this->dotcount % 100 == 0) { - echo '
'; - } - flush(); - $output = shell_exec($this->phppath . ' -d max_execution_time=5 -d short_open_tag= -l ' . escapeshellarg($filepath)); - $this->assertTrue(strpos($output, 'No syntax errors detected') === 0, $output); -// This generates so many fails that it is currently useless. -// $this->assertTrue(stripos(file_get_contents($filepath), "\t") === false, -// "File $filepath contains a tab character."); - } -} -?> diff --git a/lib/simpletest/testaccesslib.php b/lib/simpletest/testaccesslib.php index 69c615d086..0f307bf338 100644 --- a/lib/simpletest/testaccesslib.php +++ b/lib/simpletest/testaccesslib.php @@ -12,7 +12,7 @@ if (!defined('MOODLE_INTERNAL')) { die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page } -class accesslib_test extends MoodleUnitTestCase { +class accesslib_test extends FakeDBUnitTestCase { function test_get_parent_contexts() { $context = get_context_instance(CONTEXT_SYSTEM); diff --git a/lib/simpletest/testajaxlib.php b/lib/simpletest/testajaxlib.php index 16ef0b20e4..f685ad9ff5 100644 --- a/lib/simpletest/testajaxlib.php +++ b/lib/simpletest/testajaxlib.php @@ -39,7 +39,7 @@ if (!defined('MOODLE_INTERNAL')) { require_once($CFG->libdir . '/moodlelib.php'); require_once($CFG->libdir . '/ajax/ajaxlib.php'); -class ajaxlib_test extends MoodleUnitTestCase { +class ajaxlib_test extends FakeDBUnitTestCase { var $user_agents = array( 'MSIE' => array( diff --git a/lib/simpletest/testbackuplib.php b/lib/simpletest/testbackuplib.php index 1a0da5427b..233f58cfc4 100644 --- a/lib/simpletest/testbackuplib.php +++ b/lib/simpletest/testbackuplib.php @@ -36,16 +36,8 @@ if (!defined('MOODLE_INTERNAL')) { } require_once($CFG->dirroot . '/backup/backuplib.php'); -Mock::generate('ADODB_mysql'); -Mock::generate('ADORecordSet_mysql'); -class backuplib_test extends MoodleUnitTestCase { - var $real_db; - var $real_dataroot; - var $rs; - var $firstcolumn; - var $testfiles = array(); - var $userbasedir; +class backuplib_test extends UnitTestCase { } diff --git a/lib/simpletest/testcode.php b/lib/simpletest/testcode.php index 9cd30563d4..6f7fc0da7b 100644 --- a/lib/simpletest/testcode.php +++ b/lib/simpletest/testcode.php @@ -12,7 +12,7 @@ if (!defined('MOODLE_INTERNAL')) { die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page } -class code_test extends MoodleUnitTestCase { +class code_test extends UnitTestCase { var $allok = array(); var $badstrings; diff --git a/lib/simpletest/testcompletionlib.php b/lib/simpletest/testcompletionlib.php index 2bd52894fc..4aebb9e7e5 100644 --- a/lib/simpletest/testcompletionlib.php +++ b/lib/simpletest/testcompletionlib.php @@ -87,7 +87,7 @@ class TimeModifiedExpectation extends SimpleExpectation { } } -class completionlib_test extends MoodleUnitTestCase { +class completionlib_test extends FakeDBUnitTestCase { var $realdb,$realcfg,$realsession,$realuser; function setUp() { diff --git a/lib/simpletest/testconditionlib.php b/lib/simpletest/testconditionlib.php index f5b54690e8..1258a0e44f 100644 --- a/lib/simpletest/testconditionlib.php +++ b/lib/simpletest/testconditionlib.php @@ -5,7 +5,7 @@ if (!defined('MOODLE_INTERNAL')) { require_once($CFG->dirroot . '/lib/conditionlib.php'); -class conditionlib_test extends MoodleUnitTestCase { +class conditionlib_test extends FakeDBUnitTestCase { var $oldcfg; public function setUp() { diff --git a/lib/simpletest/testeventslib.php b/lib/simpletest/testeventslib.php index 679c6d3464..5b74a3c4d2 100755 --- a/lib/simpletest/testeventslib.php +++ b/lib/simpletest/testeventslib.php @@ -74,7 +74,7 @@ class sample_handler_class { } } -class eventslib_test extends MoodleUnitTestCase { +class eventslib_test extends FakeDBUnitTestCase { private $realdb; /** * Create temporary entries in the database for these tests. diff --git a/lib/simpletest/testportfolioaddbutton.php b/lib/simpletest/testportfolioaddbutton.php index f5d73fdf5a..738497eb2a 100644 --- a/lib/simpletest/testportfolioaddbutton.php +++ b/lib/simpletest/testportfolioaddbutton.php @@ -37,7 +37,7 @@ if (!defined('MOODLE_INTERNAL')) { require_once($CFG->libdir . '/portfoliolib.php'); -class portfoliolibaddbutton_test extends MoodleUnitTestCase { +class portfoliolibaddbutton_test extends FakeDBUnitTestCase { function test_set_formats() { diff --git a/lib/simpletest/testquestionlib.php b/lib/simpletest/testquestionlib.php index 96a15e4980..65f7e9540b 100644 --- a/lib/simpletest/testquestionlib.php +++ b/lib/simpletest/testquestionlib.php @@ -37,7 +37,7 @@ if (!defined('MOODLE_INTERNAL')) { require_once($CFG->libdir . '/questionlib.php'); -class questionlib_test extends MoodleUnitTestCase { +class questionlib_test extends FakeDBUnitTestCase { function setUp() { diff --git a/lib/simpletest/testrepositorylib.php b/lib/simpletest/testrepositorylib.php index 447d113ffe..cd32e49790 100644 --- a/lib/simpletest/testrepositorylib.php +++ b/lib/simpletest/testrepositorylib.php @@ -46,7 +46,7 @@ foreach ($repository_plugins as $plugin) { Mock::generatePartial("repository_$plugin", "partialmock_$plugin", array('send_package')); } -class repositorylib_test extends MoodleUnitTestCase { +class repositorylib_test extends FakeDBUnitTestCase { function setup() { parent::setup(); diff --git a/lib/simpletest/testsimpletestlib.php b/lib/simpletest/testsimpletestlib.php index 62465e647d..bce4214486 100644 --- a/lib/simpletest/testsimpletestlib.php +++ b/lib/simpletest/testsimpletestlib.php @@ -11,7 +11,7 @@ if (!defined('MOODLE_INTERNAL')) { die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page } -class simpletestlib_test extends MoodleUnitTestCase { +class simpletestlib_test extends FakeDBUnitTestCase { function test_load_delete_test_data() { global $DB; diff --git a/lib/simpletestlib.php b/lib/simpletestlib.php index 4e09e66eca..263d2df73a 100644 --- a/lib/simpletestlib.php +++ b/lib/simpletestlib.php @@ -149,7 +149,7 @@ class CheckSpecifiedFieldsExpectation extends SimpleExpectation { } } -class MoodleUnitTestCase extends UnitTestCase { +class FakeDBUnitTestCase extends UnitTestCase { public $tables = array(); public $pkfile; public $cfg; @@ -181,7 +181,7 @@ class MoodleUnitTestCase extends UnitTestCase { $tabledata = ''; foreach ($tables as $table) { - if ($table != 'sessions2') { + if ($table != 'sessions') { if (!$max_id = $DB->get_field_sql("SELECT MAX(id) FROM {$CFG->unittestprefix}{$table}")) { $max_id = 0; } diff --git a/mod/quiz/simpletest/testaccessrules.php b/mod/quiz/simpletest/testaccessrules.php index 2c767c80ed..957380c84c 100644 --- a/mod/quiz/simpletest/testaccessrules.php +++ b/mod/quiz/simpletest/testaccessrules.php @@ -14,7 +14,7 @@ if (!defined('MOODLE_INTERNAL')) { require_once($CFG->dirroot . '/mod/quiz/locallib.php'); -class simple_rules_test extends MoodleUnitTestCase { +class simple_rules_test extends FakeDBUnitTestCase { function test_num_attempts_access_rule() { $quiz = new stdClass; $quiz->attempts = 3; @@ -89,7 +89,7 @@ class simple_rules_test extends MoodleUnitTestCase { } } -class open_close_date_access_rule_test extends MoodleUnitTestCase { +class open_close_date_access_rule_test extends FakeDBUnitTestCase { function test_no_dates() { $quiz = new stdClass; $quiz->timeopen = 0; @@ -211,7 +211,7 @@ class open_close_date_access_rule_test extends MoodleUnitTestCase { } } -class inter_attempt_delay_access_rule_test extends MoodleUnitTestCase { +class inter_attempt_delay_access_rule_test extends FakeDBUnitTestCase { function test_just_first_delay() { $quiz = new stdClass; $quiz->attempts = 3; @@ -361,7 +361,7 @@ class inter_attempt_delay_access_rule_test extends MoodleUnitTestCase { } } -class password_access_rule_test extends MoodleUnitTestCase { +class password_access_rule_test extends FakeDBUnitTestCase { function test_password_access_rule() { $quiz = new stdClass; $quiz->password = 'frog'; @@ -417,7 +417,7 @@ class password_access_rule_test extends MoodleUnitTestCase { } } -class securewindow_access_rule_test extends MoodleUnitTestCase { +class securewindow_access_rule_test extends FakeDBUnitTestCase { // Nothing very testable in this class, just test that it obeys the general access rule contact. function test_securewindow_access_rule() { @@ -436,7 +436,7 @@ class securewindow_access_rule_test extends MoodleUnitTestCase { } } -class quiz_access_manager_test extends MoodleUnitTestCase { +class quiz_access_manager_test extends FakeDBUnitTestCase { // TODO } ?> diff --git a/mod/quiz/simpletest/testlib.php b/mod/quiz/simpletest/testlib.php index ba9fe2cc57..f39d94a582 100644 --- a/mod/quiz/simpletest/testlib.php +++ b/mod/quiz/simpletest/testlib.php @@ -13,7 +13,7 @@ if (!defined('MOODLE_INTERNAL')) { require_once($CFG->dirroot . '/mod/quiz/lib.php'); -class quiz_lib_test extends MoodleUnitTestCase { +class quiz_lib_test extends FakeDBUnitTestCase { function test_quiz_has_grades() { $quiz = new stdClass; $quiz->grade = '100.0000'; diff --git a/mod/quiz/simpletest/testlocallib.php b/mod/quiz/simpletest/testlocallib.php index 75beb6830d..d90d5d9eb0 100644 --- a/mod/quiz/simpletest/testlocallib.php +++ b/mod/quiz/simpletest/testlocallib.php @@ -13,7 +13,7 @@ if (!defined('MOODLE_INTERNAL')) { require_once($CFG->dirroot . '/mod/quiz/locallib.php'); -class quiz_locallib_test extends MoodleUnitTestCase { +class quiz_locallib_test extends FakeDBUnitTestCase { function test_quiz_questions_in_quiz() { $this->assertEqual(quiz_questions_in_quiz(''), ''); $this->assertEqual(quiz_questions_in_quiz('0'), ''); diff --git a/question/type/numerical/simpletest/testquestiontype.php b/question/type/numerical/simpletest/testquestiontype.php index a9da903c9e..f4ea37f25c 100644 --- a/question/type/numerical/simpletest/testquestiontype.php +++ b/question/type/numerical/simpletest/testquestiontype.php @@ -14,7 +14,7 @@ if (!defined('MOODLE_INTERNAL')) { require_once($CFG->dirroot . '/question/type/numerical/questiontype.php'); -class question_numerical_qtype_test extends MoodleUnitTestCase { +class question_numerical_qtype_test extends FakeDBUnitTestCase { var $tolerance = 0.00000001; var $qtype; diff --git a/question/type/shortanswer/simpletest/testquestiontype.php b/question/type/shortanswer/simpletest/testquestiontype.php index dacf5e06bb..3773e0677e 100644 --- a/question/type/shortanswer/simpletest/testquestiontype.php +++ b/question/type/shortanswer/simpletest/testquestiontype.php @@ -14,7 +14,7 @@ if (!defined('MOODLE_INTERNAL')) { require_once($CFG->dirroot . '/question/type/questiontype.php'); -class question_shortanswer_qtype_test extends MoodleUnitTestCase { +class question_shortanswer_qtype_test extends FakeDBUnitTestCase { var $qtype; function setUp() {