Skip to content

Commit

Permalink
Merge branch 'MDL-74413' of https://github.com/stronk7/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
junpataleta committed May 12, 2022
2 parents aa88375 + caf55ab commit eae7ec3
Show file tree
Hide file tree
Showing 106 changed files with 1,067 additions and 1,493 deletions.
20 changes: 10 additions & 10 deletions filter/mathjaxloader/tests/filtermath_test.php
Expand Up @@ -13,24 +13,24 @@
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Provides the {@link filter_mathjaxloader_filtermath_testcase} class.
*
* @package filter_mathjaxloader
* @category test
* @copyright 2018 Markku Riekkinen
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace filter_mathjaxloader;

use filter_mathjaxloader;

defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->dirroot.'/filter/mathjaxloader/filter.php');

/**
* Unit tests for the MathJax loader filter.
*
* @package filter_mathjaxloader
* @category test
* @copyright 2018 Markku Riekkinen
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class filter_mathjaxloader_filtermath_testcase extends advanced_testcase {
class filtermath_test extends \advanced_testcase {

/**
* Test the functionality of {@link filter_mathjaxloader::filter()}.
Expand All @@ -41,7 +41,7 @@ class filter_mathjaxloader_filtermath_testcase extends advanced_testcase {
* @dataProvider test_math_filtering_inputs
*/
public function test_math_filtering($inputtext, $expected) {
$filter = new filter_mathjaxloader(context_system::instance(), []);
$filter = new filter_mathjaxloader(\context_system::instance(), []);
$this->assertEquals($expected, $filter->filter($inputtext));
}

Expand Down
13 changes: 4 additions & 9 deletions grade/grading/form/guide/tests/guide_test.php
Expand Up @@ -14,14 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Unit tests for Marking Guide grading method.
*
* @package gradingform_guide
* @category test
* @copyright 2015 Nikita Kalinin <nixorv@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace gradingform_guide;

use gradingform_controller;

defined('MOODLE_INTERNAL') || die();

Expand All @@ -37,7 +32,7 @@
* @copyright 2015 Nikita Kalinin <nixorv@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class gradingform_guide_testcase extends advanced_testcase {
class guide_test extends \advanced_testcase {
/**
* Unit test to get draft instance and create new instance.
*/
Expand Down
42 changes: 12 additions & 30 deletions grade/grading/tests/grading_manager_test.php
Expand Up @@ -14,42 +14,24 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Unit tests for the advanced grading subsystem
*
* @package core_grading
* @category phpunit
* @copyright 2011 David Mudrak <david@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core_grading;

use grading_manager;

defined('MOODLE_INTERNAL') || die();

global $CFG;
require_once($CFG->dirroot . '/grade/grading/lib.php'); // Include the code to test


/**
* Makes protected method accessible for testing purposes
*
* @package core_grading
* @category phpunit
* @copyright 2011 David Mudrak <david@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class testable_grading_manager extends grading_manager {
}


/**
* Test cases for the grading manager API
*
* @package core_grading
* @category phpunit
* @category test
* @copyright 2011 David Mudrak <david@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class core_grade_grading_manager_testcase extends advanced_testcase {
class grading_manager_test extends \advanced_testcase {
public function test_basic_instantiation() {
$manager1 = get_grading_manager();

Expand Down Expand Up @@ -103,7 +85,7 @@ public function test_set_and_get_grading_area() {
$this->assertEquals('rubric', $gradingman->get_active_method());

// attempting to set an invalid method
$this->expectException(moodle_exception::class);
$this->expectException(\moodle_exception::class);
$gradingman->set_active_method('no_one_should_ever_try_to_implement_a_method_with_this_silly_name');
}

Expand All @@ -115,27 +97,27 @@ public function test_tokenize() {
$UTFfailuremessage = 'A test using UTF-8 characters has failed. Consider updating PHP and PHP\'s PCRE or INTL extensions (MDL-30494)';

$needle = " šašek, \n\n \r a král; \t";
$tokens = testable_grading_manager::tokenize($needle);
$tokens = grading_manager::tokenize($needle);
$this->assertEquals(2, count($tokens), $UTFfailuremessage);
$this->assertTrue(in_array('šašek', $tokens), $UTFfailuremessage);
$this->assertTrue(in_array('král', $tokens), $UTFfailuremessage);

$needle = ' " šašek a král " ';
$tokens = testable_grading_manager::tokenize($needle);
$tokens = grading_manager::tokenize($needle);
$this->assertEquals(1, count($tokens));
$this->assertTrue(in_array('šašek a král', $tokens));

$needle = '""';
$tokens = testable_grading_manager::tokenize($needle);
$tokens = grading_manager::tokenize($needle);
$this->assertTrue(empty($tokens));

$needle = '"0"';
$tokens = testable_grading_manager::tokenize($needle);
$tokens = grading_manager::tokenize($needle);
$this->assertEquals(1, count($tokens));
$this->assertTrue(in_array('0', $tokens));

$needle = '<span>Aha</span>, then who\'s a bad guy here he?';
$tokens = testable_grading_manager::tokenize($needle);
$tokens = grading_manager::tokenize($needle);
$this->assertEquals(8, count($tokens));
$this->assertTrue(in_array('span', $tokens)); // Extracted the tag name
$this->assertTrue(in_array('Aha', $tokens));
Expand All @@ -144,7 +126,7 @@ public function test_tokenize() {
$this->assertTrue(in_array('he', $tokens)); // Removed the trailing ?
$needle = 'grammar, "english language"';
$tokens = testable_grading_manager::tokenize($needle);
$tokens = grading_manager::tokenize($needle);
$this->assertTrue(in_array('grammar', $tokens));
$this->assertTrue(in_array('english', $tokens));
$this->assertTrue(in_array('language', $tokens));
Expand Down

0 comments on commit eae7ec3

Please sign in to comment.