X-Git-Url: http://git.moodle.org/gw?p=moodle.git;a=blobdiff_plain;f=lib%2Ftests%2Fsetuplib_test.php;h=63431ee0efc2f82aac2078d85b1e6774d78b82fc;hp=30a257bd50e68d3ed5d9a8b64c6554e5f0670347;hb=8d220cb552d9c55b98aef70e2f40ef560efeb79b;hpb=3ecc63e9dbe29c6a5a8f65fa8e7980ba0fffb5a8 diff --git a/lib/tests/setuplib_test.php b/lib/tests/setuplib_test.php index 30a257bd50e..63431ee0efc 100644 --- a/lib/tests/setuplib_test.php +++ b/lib/tests/setuplib_test.php @@ -118,4 +118,28 @@ class core_setuplib_testcase extends basic_testcase { $this->assertTrue(is_web_crawler(), "$agent should be considered a search engine"); } } + + /** + * Test if get_exception_info() removes file system paths + */ + public function test_exception_info_removes_serverpaths() { + global $CFG; + + // This doesn't test them all possible ones, but these are set for unit tests. + $cfgnames = array('dataroot', 'dirroot', 'tempdir', 'cachedir'); + + $fixture = ''; + $expected = ''; + foreach ($cfgnames as $cfgname) { + if (!empty($CFG->$cfgname)) { + $fixture .= $CFG->$cfgname.' '; + $expected .= "[$cfgname] "; + } + } + $exception = new moodle_exception('generalexceptionmessage', 'error', '', $fixture, $fixture); + $exceptioninfo = get_exception_info($exception); + + $this->assertContains($expected, $exceptioninfo->message, 'Exception message does not contain system paths'); + $this->assertContains($expected, $exceptioninfo->debuginfo, 'Exception debug info does not contain system paths'); + } }