mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 02:16:41 +02:00
MDL-37813 remove missing filters when configuring string filters and fix filter uninstall
This commit is contained in:
parent
4e47920f08
commit
a67ea663b1
3 changed files with 59 additions and 14 deletions
|
@ -606,23 +606,39 @@ class core_filterlib_testcase extends advanced_testcase {
|
|||
|
||||
public function test_set() {
|
||||
global $CFG;
|
||||
|
||||
$this->assertFileExists("$CFG->dirroot/filter/emailprotect"); // Any standard filter.
|
||||
$this->assertFileExists("$CFG->dirroot/filter/tidy"); // Any standard filter.
|
||||
$this->assertFileNotExists("$CFG->dirroot/filter/grgrggr"); // Any non-existent filter
|
||||
|
||||
// Setup fixture.
|
||||
$CFG->filterall = 0;
|
||||
$CFG->stringfilters = '';
|
||||
set_config('filterall', 0);
|
||||
set_config('stringfilters', '');
|
||||
// Exercise SUT.
|
||||
filter_set_applies_to_strings('name', true);
|
||||
filter_set_applies_to_strings('tidy', true);
|
||||
// Validate.
|
||||
$this->assertEquals('name', $CFG->stringfilters);
|
||||
$this->assertEquals('tidy', $CFG->stringfilters);
|
||||
$this->assertEquals(1, $CFG->filterall);
|
||||
|
||||
filter_set_applies_to_strings('grgrggr', true);
|
||||
$this->assertEquals('tidy', $CFG->stringfilters);
|
||||
$this->assertEquals(1, $CFG->filterall);
|
||||
|
||||
filter_set_applies_to_strings('emailprotect', true);
|
||||
$this->assertEquals('tidy,emailprotect', $CFG->stringfilters);
|
||||
$this->assertEquals(1, $CFG->filterall);
|
||||
}
|
||||
|
||||
public function test_unset_to_empty() {
|
||||
global $CFG;
|
||||
|
||||
$this->assertFileExists("$CFG->dirroot/filter/tidy"); // Any standard filter.
|
||||
|
||||
// Setup fixture.
|
||||
$CFG->filterall = 1;
|
||||
$CFG->stringfilters = 'name';
|
||||
set_config('filterall', 1);
|
||||
set_config('stringfilters', 'tidy');
|
||||
// Exercise SUT.
|
||||
filter_set_applies_to_strings('name', false);
|
||||
filter_set_applies_to_strings('tidy', false);
|
||||
// Validate.
|
||||
$this->assertEquals('', $CFG->stringfilters);
|
||||
$this->assertEquals('', $CFG->filterall);
|
||||
|
@ -630,13 +646,18 @@ class core_filterlib_testcase extends advanced_testcase {
|
|||
|
||||
public function test_unset_multi() {
|
||||
global $CFG;
|
||||
|
||||
$this->assertFileExists("$CFG->dirroot/filter/emailprotect"); // Any standard filter.
|
||||
$this->assertFileExists("$CFG->dirroot/filter/tidy"); // Any standard filter.
|
||||
$this->assertFileExists("$CFG->dirroot/filter/multilang"); // Any standard filter.
|
||||
|
||||
// Setup fixture.
|
||||
$CFG->filterall = 1;
|
||||
$CFG->stringfilters = 'name,other';
|
||||
set_config('filterall', 1);
|
||||
set_config('stringfilters', 'emailprotect,tidy,multilang');
|
||||
// Exercise SUT.
|
||||
filter_set_applies_to_strings('name', false);
|
||||
filter_set_applies_to_strings('tidy', false);
|
||||
// Validate.
|
||||
$this->assertEquals('other', $CFG->stringfilters);
|
||||
$this->assertEquals('emailprotect,multilang', $CFG->stringfilters);
|
||||
$this->assertEquals(1, $CFG->filterall);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue