MDL-67169 phpunit: fix clear flaw in unit test provider

Basically the provider is ignoring the CRLF to LF normalization
results and loading the original file again.

This doesn't have any impact normally, because all moodle
files are LF ones and people using other systems have their
git configurations set to work that way (not modify or force LF).

But there may be checkouts out there (for example travis) where
the git configuration by defult is to convert to the OS, causing
windows runs to fail badly there. See the issue for more info
and links.
This commit is contained in:
Eloy Lafuente (stronk7) 2019-11-06 23:58:30 +01:00
parent 01aa126848
commit a5cd14e4d8

View file

@ -111,7 +111,7 @@ class core_messageinbound_testcase extends advanced_testcase {
// Break on the --[TOKEN]-- tags in the file. // Break on the --[TOKEN]-- tags in the file.
$content = file_get_contents($file->getRealPath()); $content = file_get_contents($file->getRealPath());
$content = preg_replace("#\r\n#", "\n", $content); $content = preg_replace("#\r\n#", "\n", $content);
$tokens = preg_split('#(?:^|\n*)----([A-Z]+)----\n#', file_get_contents($file->getRealPath()), $tokens = preg_split('#(?:^|\n*)----([A-Z]+)----\n#', $content,
null, PREG_SPLIT_DELIM_CAPTURE); null, PREG_SPLIT_DELIM_CAPTURE);
$sections = array( $sections = array(
// Key => Required. // Key => Required.