after_restore_course assumes all courses use this format.

Issue #4 resolved
info ewallah created an issue

The line

$currentfilterbarsetting = $DB->get_record('course_format_options', array('name' => 'displayfilterbar', 'format' => 'tiles', 'courseid' => $this->step->get_task()->get_courseid()));

does not check if a record was returned or not. So a lot of phpunit tests throw errors because the currentfilterbarsetting is empty.

Better to use something like

if ($currentfilterbarsetting = $DB->get_record( 'course_format_options', ['name' => 'displayfilterbar', 'format' => 'tiles', 'courseid' => $this->step->get_task()->get_courseid()])) {
....
}

vendor/bin/phpunit "core_course_courselib_testcase" course/tests/courselib_test.php Before:

................................E...E..........E...............  63 / 118 ( 53%)
......F................................................         118 / 118 (100%)

There were 3 errors:

1) core_course_courselib_testcase::test_course_restored_event
Trying to get property 'value' of non-object

2) core_course_courselib_testcase::test_course_module_created_event
ddl_change_structure_exception: DDL sql execution error (ERROR:  table "z_backup_ids_temp" does not exist

3) core_course_courselib_testcase::test_duplicate_module
ddl_exception: Table "backup_files_temp" already exists

There was 1 failure:

1) core_course_courselib_testcase::test_async_module_deletion_hook_implemented
Failed asserting that null is an instance of class "\core\event\course_module_deleted".

ERRORS!
Tests: 118, Assertions: 1050, Errors: 3, Failures: 1.

After:

...............................................................  63 / 118 ( 53%)
.......................................................         118 / 118 (100%)

OK (118 tests, 1089 assertions)

Comments (2)

  1. David Watson repo owner

    Thanks very much for this report. On re-running vendor/bin/phpunit course/tests/courselib_test.php it seems to report no issue now but please let me know if it persists at your end

  2. Log in to comment