MDL-50153 messageinbound: Normalise line endings instead of rtrim

This commit is contained in:
Andrew Nicols 2015-05-08 15:36:10 +08:00
parent 217d7f6f24
commit 802dbbf882

View File

@ -50,9 +50,10 @@ class core_messageinbound_testcase extends advanced_testcase {
$messagedata->html = '';
list($message, $format) = test_handler::remove_quoted_text($messagedata);
list ($message, $expectedplain) = preg_replace("#\r\n#", "\n", array($message, $expectedplain));
// Trim both the expected and the actual - we are not concerned about trailing whitespace.
$this->assertEquals(rtrim($expectedplain), rtrim($message));
// Normalise line endings on both strings.
$this->assertEquals($expectedplain, $message);
$this->assertEquals(FORMAT_PLAIN, $format);
}
@ -63,8 +64,9 @@ class core_messageinbound_testcase extends advanced_testcase {
list($message, $format) = test_handler::remove_quoted_text($messagedata);
// Trim both the expected and the actual - we are not concerned about trailing whitespace.
$this->assertEquals(rtrim($expectedhtml), rtrim($message));
// Normalise line endings on both strings.
list ($message, $expectedhtml) = preg_replace("#\r\n#", "\n", array($message, $expectedhtml));
$this->assertEquals($expectedhtml, $message);
$this->assertEquals(FORMAT_PLAIN, $format);
}
}
@ -107,7 +109,9 @@ class core_messageinbound_testcase extends advanced_testcase {
protected function read_test_file(\SplFileInfo $file, $fixturesdir) {
// Break on the --[TOKEN]-- tags in the file.
$tokens = preg_split('#(?:^|[\r]?\n*)----([A-Z]+)----[\r]?\n#', file_get_contents($file->getRealPath()),
$content = file_get_contents($file->getRealPath());
$content = preg_replace("#\r\n#", "\n", $content);
$tokens = preg_split('#(?:^|\n*)----([A-Z]+)----\n#', file_get_contents($file->getRealPath()),
null, PREG_SPLIT_DELIM_CAPTURE);
$sections = array(
// Key => Required.