lithium\test\Unit::_normalizeLineEndings()

protected method

Fixes some issues regarding the used EOL character(s).

On linux EOL is LF, on Windows it is normally CRLF, but the latter may depend also on the git config core.autocrlf setting. As some tests use heredoc style (<<<) to specify multiline expectations, this EOL issue may cause tests to fail only because of a difference in EOL's used.

in assertEqual, assertNotEqual,` assertPattern and assertNotPattern this function is called to get rid of any EOL differences.

Parameters

  • mixed $expected
  • mixed $result

Returns

array

Array with the normalized elements i.e. array($expected, $result).

Source

	protected function _normalizeLineEndings($expected, $result) {
		if (is_string($expected) && is_string($result)) {
			$expected = preg_replace('/\r\n/', "\n", $expected);
			$result = preg_replace('/\r\n/', "\n", $result);
		}
		return [$expected, $result];
	}