Closed kenjis closed 9 years ago
Some tests fail on Windows, probably because of EOL code.
In my opinion, all EOL code in HTML output should be \n
. But Fuel might not think so.
Which is better?
\n
PHP_EOL
I don't have a strong opinion on this subject (other than the fact that Microsoft should drop the CR, a newline is a newline ;-)).
Tests however should validate on all platforms. If the HTML generated is platform dependent, so should the expected values be.
Having said this, in the first test that fails, the code uses a HEREDOC, so the line-ends are part of the code. All Fuel source uses unix line-ends, so if your tests reveil that CRLF is returned, it suggests you did a checkout of the code without preserving line-ends.
This can't be dealt with, since it's outside the control of either the code or the test.
If the HTML generated is platform dependent
Now it is, because Fuel uses PHP_EOL
in code to generate HTML like below:
echo '<strong>Variable #'.$i.':</strong>'.PHP_EOL;
I guess you have an opinion, but you don't notice, do you? This is not because of Microsoft, only Fuel's code. (Of course if Microsoft used the same EOL as Unix, we don't have to think of this at all.)
For example, if the code above is right, we should fix the test code, because it uses "\n"
.
I could ask the same question in other way like this: Sould HTML generated be platform dependent or not?
You failed to see my point.
The code that gives the error in your opening post, is
$var = <<<HTML
line 1
line 2
line 4
HTML;
which means no PHP_EOL or hardcoded line-ends are used, but the line-ends you get are the one's used for the php file itself. Which for Fuel php files is always "\n", since we use unix line-ends as standard.
So the test should ALWAYS return a string with "\n" in it, no matter on which platform you run it. The only way you get CRLF is if you did a git clone without preserving line-ends.
So the code is right, and the test is right. Nothing to change.
As to what is generated, I have no real preference. I'd personally go for unix line-ends, since it's a byte less, and it's less typing. But I would say PHP_EOL is logical, so a Windows app generates CRLF (which Windows users would expect).
FuelPHP 1.7.2 and 1.8/develop PHP 5.5.11