diff --git a/files/tests/externallib_test.php b/files/tests/externallib_test.php index 4f197775f31..76cf28b76c5 100644 --- a/files/tests/externallib_test.php +++ b/files/tests/externallib_test.php @@ -145,7 +145,8 @@ class core_files_externallib_testcase extends advanced_testcase { $instanceid = null; // Make sure the file is created. - $fileinfo = @core_files_external::upload($contextid, $component, $filearea, $itemid, $filepath, $filename, $filecontent); + $fileinfo = core_files_external::upload($contextid, $component, $filearea, $itemid, $filepath, $filename, $filecontent, + 'user', $USER->id); $fileinfo = external_api::clean_returnvalue(core_files_external::upload_returns(), $fileinfo); $browser = get_file_browser(); $file = $browser->get_file_info($context, $component, $filearea, $itemid, $filepath, $filename); diff --git a/lib/dml/tests/dml_test.php b/lib/dml/tests/dml_test.php index 85658f01c48..5aaf56b0eb5 100644 --- a/lib/dml/tests/dml_test.php +++ b/lib/dml/tests/dml_test.php @@ -4177,6 +4177,9 @@ class core_dml_testcase extends database_driver_testcase { $this->fail("Expecting an exception, none occurred"); } catch (moodle_exception $e) { $this->assertInstanceOf('coding_exception', $e); + } catch (Error $error) { + // PHP 7.1 throws Error even earlier. + $this->assertRegExp('/Too few arguments to function/', $error->getMessage()); } // Cover the function using placeholders in all positions. diff --git a/lib/tests/moodlelib_test.php b/lib/tests/moodlelib_test.php index d9c53fc0187..e322a9bce21 100644 --- a/lib/tests/moodlelib_test.php +++ b/lib/tests/moodlelib_test.php @@ -202,12 +202,18 @@ class core_moodlelib_testcase extends advanced_testcase { $this->fail('coding_exception expected'); } catch (moodle_exception $ex) { $this->assertInstanceOf('coding_exception', $ex); + } catch (Error $error) { + // PHP 7.1 throws Error even earlier. + $this->assertRegExp('/Too few arguments to function/', $error->getMessage()); } try { @optional_param('username'); $this->fail('coding_exception expected'); } catch (moodle_exception $ex) { $this->assertInstanceOf('coding_exception', $ex); + } catch (Error $error) { + // PHP 7.1 throws Error even earlier. + $this->assertRegExp('/Too few arguments to function/', $error->getMessage()); } try { optional_param('', 'default_user', PARAM_RAW); @@ -248,12 +254,18 @@ class core_moodlelib_testcase extends advanced_testcase { $this->fail('coding_exception expected'); } catch (moodle_exception $ex) { $this->assertInstanceOf('coding_exception', $ex); + } catch (Error $error) { + // PHP 7.1 throws Error even earlier. + $this->assertRegExp('/Too few arguments to function/', $error->getMessage()); } try { @optional_param_array('username'); $this->fail('coding_exception expected'); } catch (moodle_exception $ex) { $this->assertInstanceOf('coding_exception', $ex); + } catch (Error $error) { + // PHP 7.1 throws Error even earlier. + $this->assertRegExp('/Too few arguments to function/', $error->getMessage()); } try { optional_param_array('', array('a'=>'default_user'), PARAM_RAW); @@ -305,6 +317,9 @@ class core_moodlelib_testcase extends advanced_testcase { $this->fail('coding_exception expected'); } catch (moodle_exception $ex) { $this->assertInstanceOf('coding_exception', $ex); + } catch (Error $error) { + // PHP 7.1 throws Error even earlier. + $this->assertRegExp('/Too few arguments to function/', $error->getMessage()); } try { required_param('username', ''); @@ -348,6 +363,9 @@ class core_moodlelib_testcase extends advanced_testcase { $this->fail('coding_exception expected'); } catch (moodle_exception $ex) { $this->assertInstanceOf('coding_exception', $ex); + } catch (Error $error) { + // PHP 7.1 throws Error. + $this->assertRegExp('/Too few arguments to function/', $error->getMessage()); } try { required_param_array('', PARAM_RAW); @@ -409,6 +427,9 @@ class core_moodlelib_testcase extends advanced_testcase { $this->fail('moodle_exception expected'); } catch (moodle_exception $ex) { $this->assertInstanceOf('moodle_exception', $ex); + } catch (Error $error) { + // PHP 7.1 throws Error even earlier. + $this->assertRegExp('/Too few arguments to function/', $error->getMessage()); } } @@ -429,6 +450,9 @@ class core_moodlelib_testcase extends advanced_testcase { $this->fail('moodle_exception expected'); } catch (moodle_exception $ex) { $this->assertInstanceOf('moodle_exception', $ex); + } catch (Error $error) { + // PHP 7.1 throws Error even earlier. + $this->assertRegExp('/Too few arguments to function/', $error->getMessage()); } try {