Merge branch 'MDL-45221-master' of git://github.com/andrewnicols/moodle

This commit is contained in:
Sam Hemelryk
2014-04-29 09:10:05 +12:00
3 changed files with 31 additions and 1 deletions
+1 -1
View File
@@ -2466,7 +2466,7 @@ class admin_setting_configexecutable extends admin_setting_configfile {
$default = $this->get_defaultsetting();
if ($data) {
if (file_exists($data) and is_executable($data)) {
if (file_exists($data) and !is_dir($data) and is_executable($data)) {
$executable = '<span class="pathok">&#x2714;</span>';
} else {
$executable = '<span class="patherror">&#x2718;</span>';
+30
View File
@@ -111,6 +111,36 @@ class core_admintree_testcase extends advanced_testcase {
$tree->add('root', new admin_category('bar', 'Bar'), '');
}
/**
* Testing whether a configexecutable setting is executable.
*/
public function test_admin_setting_configexecutable() {
global $CFG;
$this->resetAfterTest();
$executable = new admin_setting_configexecutable('test1', 'Text 1', 'Help Path', '');
// Check for an invalid path.
$result = $executable->output_html($CFG->dirroot . '/lib/tests/other/file_does_not_exist');
$this->assertRegexp('/class="patherror"/', $result);
// Check for a directory.
$result = $executable->output_html($CFG->dirroot);
$this->assertRegexp('/class="patherror"/', $result);
// Check for a file which is not executable.
$result = $executable->output_html($CFG->dirroot . '/config.php');
$this->assertRegexp('/class="patherror"/', $result);
// Check for an executable file.
$result = $executable->output_html($CFG->dirroot . '/lib/tests/other/executable.php');
$this->assertRegexp('/class="pathok"/', $result);
// Check for no file specified.
$result = $executable->output_html('');
$this->assertRegexp('/name="s__test1" value=""/', $result);
}
/**
* Saving of values.
*/
View File