silverstripe/sapphire — pull request #879 by tractorcow (2012-10-16 04:20:35+00:00)
Title: BUG / API Fixes to test cases requiring code for consolidating newlines

Through the test cases there are many cases where string comparison is highly dependent upon environment.

In order to alleviate some of these issues this code introduces a new Convert::nl2os function which allows newline characters to be normalised across environments. This function may be called on its own to convert any newline sequences within a string to match those used by the current operating system, or a sequence may be specified in order to convert to a foreign system.

Test cases are included to test the correctness of this function.

Various test cases have been updated in order to remove the variability of line endings from string comparison in cases where this is not critical. This should now allow test cases to run identically across any environment.

Some test cases also had issues with system depedant path separators, so realpath() has been used to normalise these.

I also noticed some issues with the tidy library appending an odd \r\n\r to any tidied string. This may be an odd glitch in that library, but I considered it safe to trim trailing and leading whitespace characters from any cleaned string. This could just be a windows thing. Please correct me if this is an incorrect consideration.

I also managed to somehow correctly squash and rebase these commits, for the first time ever. Thanks Sam for the tutorial. :)