Hola!
I noticed something very strange in unit tests for /languages/Language.php (/tests/phpunit/languages/LanguageTest.php):
Language::sprintfDate() is tested to conform with expected formatted date strings. In the test file method 'provideSprintfDateSamples' provides a test case for the format bit 'W' which means "ISO 8601 week number, zero-padded". Language::sprintfDate() outputs the result for W as documented. However, one of the test cases for this format contains expected value "1" (instead of "01"). As I said above, sprintfDate() adds a zero (printing "01"), but when I run the tests, they just pass!
What is wrong here? Wrong test case + issue in PHPUnit or what?
On Fri, Jun 7, 2013 at 12:36 PM, Paul Selitskas p.selitskas@gmail.com wrote:
What is wrong here? Wrong test case + issue in PHPUnit or what?
Fun with PHP comparison. With the "==" and "!=" operators (which are what PHPUnit's assertEquals is probably using), PHP notices that "1" and "01" are both "numeric strings" so it decides to compare them as numbers.
http://php.net/manual/en/language.operators.comparison.php
What Brad said. In this case, I believe the assertSame function should be used instead, which emulates ===. On Jun 7, 2013 1:55 PM, "Brad Jorsch" bjorsch@wikimedia.org wrote:
On Fri, Jun 7, 2013 at 12:36 PM, Paul Selitskas p.selitskas@gmail.com wrote:
What is wrong here? Wrong test case + issue in PHPUnit or what?
Fun with PHP comparison. With the "==" and "!=" operators (which are what PHPUnit's assertEquals is probably using), PHP notices that "1" and "01" are both "numeric strings" so it decides to compare them as numbers.
http://php.net/manual/en/language.operators.comparison.php
-- Brad Jorsch Software Engineer Wikimedia Foundation
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
wikitech-l@lists.wikimedia.org