Merge branch 'wip-mdl-48302-m28' of https://github.com/rajeshtaneja/moodle into MOODLE_28_STABLE
This commit is contained in:
@@ -92,8 +92,8 @@ Feature: Block activity modules
|
||||
| activity | name | intro | course | idnumber |
|
||||
| assign | Test assignment name | Test assignment description | C1 | assign1 |
|
||||
| book | Test book name | Test book description | C1 | book1 |
|
||||
| choice | Test choice name | Test choice description | C1 | choice1 |
|
||||
| chat | Test chat name | Test chat description | C1 | chat1 |
|
||||
| choice | Test choice name | Test choice description | C1 | choice1 |
|
||||
| data | Test database name | Test database description | C1 | data1 |
|
||||
| feedback | Test feedback name | Test feedback description | C1 | feedback1 |
|
||||
| folder | Test folder name | Test folder description | C1 | folder1 |
|
||||
|
||||
@@ -290,4 +290,31 @@ class behat_util extends testing_util {
|
||||
return behat_command::get_behat_dir() . '/test_environment_enabled.txt';
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset contents of all database tables to initial values, reset caches, etc.
|
||||
*/
|
||||
public static function reset_all_data() {
|
||||
// Reset all static caches.
|
||||
accesslib_clear_all_caches(true);
|
||||
// Reset the nasty strings list used during the last test.
|
||||
nasty_strings::reset_used_strings();
|
||||
|
||||
filter_manager::reset_caches();
|
||||
|
||||
// Reset course and module caches.
|
||||
if (class_exists('format_base')) {
|
||||
// If file containing class is not loaded, there is no cache there anyway.
|
||||
format_base::reset_course_cache(0);
|
||||
}
|
||||
get_fast_modinfo(0, 0, true);
|
||||
|
||||
// Inform data generator.
|
||||
self::get_data_generator()->reset();
|
||||
|
||||
// Purge dataroot directory.
|
||||
self::reset_dataroot();
|
||||
|
||||
// Reset database.
|
||||
self::reset_database();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -715,6 +715,9 @@ abstract class testing_util {
|
||||
// Do not delete automatically installed files.
|
||||
self::skip_original_data_files($childclassname);
|
||||
|
||||
// Clear file status cache, before checking file_exists.
|
||||
clearstatcache();
|
||||
|
||||
// Clean up the dataroot folder.
|
||||
$handle = opendir(self::get_dataroot());
|
||||
while (false !== ($item = readdir($handle))) {
|
||||
|
||||
@@ -123,6 +123,10 @@ class behat_hooks extends behat_base {
|
||||
throw new Exception('Behat only can run if test mode is enabled. More info in ' . behat_command::DOCS_URL . '#Running_tests');
|
||||
}
|
||||
|
||||
// Reset all data, before checking for is_server_running.
|
||||
// If not done, then it can return apache error, while running tests.
|
||||
behat_util::reset_all_data();
|
||||
|
||||
if (!behat_util::is_server_running()) {
|
||||
throw new Exception($CFG->behat_wwwroot .
|
||||
' is not available, ensure you specified correct url and that the server is set up and started.' .
|
||||
@@ -192,13 +196,7 @@ class behat_hooks extends behat_base {
|
||||
// Reset $SESSION.
|
||||
\core\session\manager::init_empty_session();
|
||||
|
||||
behat_util::reset_database();
|
||||
behat_util::reset_dataroot();
|
||||
|
||||
accesslib_clear_all_caches(true);
|
||||
|
||||
// Reset the nasty strings list used during the last test.
|
||||
nasty_strings::reset_used_strings();
|
||||
behat_util::reset_all_data();
|
||||
|
||||
// Assign valid data to admin user (some generator-related code needs a valid user).
|
||||
$user = $DB->get_record('user', array('username' => 'admin'));
|
||||
|
||||
Reference in New Issue
Block a user