From a5cd14e4d815e04d9198971dd41f25e52a3b89cb Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Wed, 6 Nov 2019 23:58:30 +0100 Subject: [PATCH] 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. --- lib/tests/messageinbound_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tests/messageinbound_test.php b/lib/tests/messageinbound_test.php index 0d4b50f6d5f..6e8cb5b8225 100644 --- a/lib/tests/messageinbound_test.php +++ b/lib/tests/messageinbound_test.php @@ -111,7 +111,7 @@ class core_messageinbound_testcase extends advanced_testcase { // Break on the --[TOKEN]-- tags in the file. $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()), + $tokens = preg_split('#(?:^|\n*)----([A-Z]+)----\n#', $content, null, PREG_SPLIT_DELIM_CAPTURE); $sections = array( // Key => Required.