From 1a0cc1615afaa5a6fb576e1f19cd1afc40a5e7ae Mon Sep 17 00:00:00 2001 From: Michael Milette Date: Tue, 7 Jun 2022 11:45:49 -0400 Subject: [PATCH] FilterCodes release 2.3.1 (2022-06-07) Fix-222: Fixed PHPUnit 9.5 compatibility. --- CHANGELOG.md | 10 ++++++---- tests/filter_test.php | 41 ++++++++++++++++++----------------------- version.php | 2 +- 3 files changed, 25 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe3abad..b5eacf2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,14 @@ # Change Log All notable changes to this project will be documented in this file. -## [2.3.1] 2022-06-02 +## [2.3.1] 2022-06-07 ### Added -phpcs.xml.cont.dist file. +- phpcs.xml.cont.dist file. ### Updated -.gitignore file. -Fix-221: Resolved conflict between {mygroups} amd {ifingroup} tags when used at the same time. +- .gitignore file. +- Fix-221: Resolved conflict between {mygroups} amd {ifingroup} tags when used at the same time. +- Fix-222: Fixed PHPUnit v9.5 compatibility. + ## [2.3.0] 2022-04-19 ### Added - New {ifhasarolename roleshortname}{/ifhasarolename} tags. diff --git a/tests/filter_test.php b/tests/filter_test.php index 486b496..6413dc6 100644 --- a/tests/filter_test.php +++ b/tests/filter_test.php @@ -23,10 +23,7 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -defined('MOODLE_INTERNAL') || die(); - -global $CFG; -require_once($CFG->dirroot . '/filter/filtercodes/filter.php'); +namespace filter_filtercodes; /** * Unit tests for FilterCodes filter. @@ -37,22 +34,22 @@ * @copyright 2017-2022 TNG Consulting Inc. - www.tngconsulting.ca * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class filter_filtercodes_testcase extends advanced_testcase { +class filter_test extends \advanced_testcase { /** - * @var filter_filtercode $filter Instance of filtercodes. - */ - protected $filter; - - /** - * Setup the test framework - * - * @return void + * Tests setup */ - protected function setUp() { + public function setUp() : void { + global $PAGE; parent::setUp(); + $this->resetAfterTest(true); - $this->filter = new filter_filtercodes(context_system::instance(), []); + $this->setAdminUser(); + + // Enable FilterCodes filter at top level. + filter_set_global_state('filtercodes', TEXTFILTER_ON); + + $PAGE->set_url(new \moodle_url('/')); } /** @@ -60,15 +57,12 @@ protected function setUp() { * * @return void */ - public function test_filter_filtercodes() { - global $CFG, $USER, $DB, $PAGE, $SITE; - - $PAGE->set_url(new moodle_url('/')); + public function test_filtercodes() { + global $CFG, $USER, $DB, $PAGE; - $this->setadminuser(); + // Create a test course. $course = $this->getDataGenerator()->create_course(); - $context = context_course::instance($course->id); - filter_set_local_state('filtercodes', $context->id, TEXTFILTER_ON); + $context = \context_course::instance($course->id); $tests = [ [ @@ -290,7 +284,8 @@ public function test_filter_filtercodes() { ]; foreach ($tests as $test) { - $this->assertEquals($test['after'], $this->filter->filter($test['before'])); + $filtered = format_text($test['before'], FORMAT_HTML, array('context' => \context_system::instance())); + $this->assertEquals($test['after'], $filtered); } } } diff --git a/version.php b/version.php index 16e04bc..ee9b280 100644 --- a/version.php +++ b/version.php @@ -25,7 +25,7 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2022041902; // The current plugin version (Date: YYYYMMDDXX). +$plugin->version = 2022060700; // The current plugin version (Date: YYYYMMDDXX). $plugin->requires = 2014051200; // Requires Moodle version 2.7 or later. $plugin->component = 'filter_filtercodes'; // Full name of the plugin (used for diagnostics). $plugin->release = '2.3.1';