mirror of
https://github.com/moodle/moodle.git
synced 2025-01-31 20:53:53 +01:00
MDL-81581 phpunit: Move multiple assert_same_xml() to common one
This commit is contained in:
parent
792698af00
commit
17237b824d
@ -602,6 +602,19 @@ abstract class question_testcase extends advanced_testcase {
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that 2 XML strings are the same, ignoring differences in line endings.
|
||||
*
|
||||
* @param string $expectedxml The expected XML string
|
||||
* @param string $xml The XML string to check
|
||||
*/
|
||||
public function assert_same_xml($expectedxml, $xml) {
|
||||
$this->assertEquals(
|
||||
str_replace("\r\n", "\n", $expectedxml),
|
||||
str_replace("\r\n", "\n", $xml)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -47,11 +47,6 @@ require_once($CFG->dirroot . '/question/engine/tests/helpers.php');
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class xmlformat_test extends \question_testcase {
|
||||
public function assert_same_xml($expectedxml, $xml) {
|
||||
$this->assertEquals(str_replace("\r\n", "\n", $expectedxml),
|
||||
str_replace("\r\n", "\n", $xml));
|
||||
}
|
||||
|
||||
public function make_test_question() {
|
||||
global $USER;
|
||||
$q = new \stdClass();
|
||||
|
@ -47,11 +47,6 @@ class question_type_test extends \question_testcase {
|
||||
$this->qtype = null;
|
||||
}
|
||||
|
||||
public function assert_same_xml($expectedxml, $xml) {
|
||||
$this->assertEquals(str_replace("\r\n", "\n", $expectedxml),
|
||||
str_replace("\r\n", "\n", $xml));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get some test question data.
|
||||
*
|
||||
|
@ -46,17 +46,6 @@ class question_type_test extends \question_testcase {
|
||||
$this->qtype = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that two strings containing XML are the same ignoring the line-endings.
|
||||
*
|
||||
* @param string $expectedxml
|
||||
* @param string $xml
|
||||
*/
|
||||
public function assert_same_xml($expectedxml, $xml) {
|
||||
$this->assertEquals(str_replace("\r\n", "\n", $expectedxml),
|
||||
str_replace("\r\n", "\n", $xml));
|
||||
}
|
||||
|
||||
public function test_save_question() {
|
||||
$this->resetAfterTest();
|
||||
|
||||
|
@ -72,17 +72,6 @@ final class questiontype_test extends \question_testcase {
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that two XML strings are the same, ignoring differences in line endings.
|
||||
*
|
||||
* @param string $expectedxml
|
||||
* @param string $xml
|
||||
*/
|
||||
public function assert_same_xml(string $expectedxml, string $xml): void {
|
||||
$this->assertEquals(str_replace("\r\n", "\n", $expectedxml),
|
||||
str_replace("\r\n", "\n", $xml));
|
||||
}
|
||||
|
||||
public function test_name(): void {
|
||||
$ordering = new qtype_ordering();
|
||||
$this->assertEquals('ordering', $ordering->name());
|
||||
|
Loading…
x
Reference in New Issue
Block a user