PhpSpreadsheet/tests/PhpSpreadsheetTests/Reader
oleibman 04e7c30758
Fix Two 32-bit Timestamp Problems, and Minor getFormattedValue Bug (#1891)
I ran the test suite using 32-bit PHP. There were 2 places where changes
were needed due to 32-bit timestamps.

Reader\\Xml.php was using strtotime as an intermediate step in converting
a string timestamp to an Excel timestamp. The XML file type stores pure timestamps
(i.e. no date portion) as, e.g., 1899-12-31T02:30:00.000, and that value
causes an error using strtotime on a 32-bit system. However, it is sufficient
to use that value in a DateTime constructor, and that will work for 32- and 64-bit.

There was no test for that particular cell, so I added one to the XML read test.
And that's when I discovered the getFormattedValue bug. The cell's format
is `hh":"mm":"ss`. The quotes around the colons are disrupting the formatting.
PhpSpreadsheet formats the cell by converting the Excel format
to a Php Date format, in this case `H\:m\:s`.
That's a problem,
since Excel thinks 'm' means *minutes*, but PHP thinks it means *months*.
This is not a problem when the colon is not quoted; there are ample tests for that.
I added my best guess as to how to recognize this situation,
changing `\:m` to `:i`. The XML read test
now succeeds, and no other tests were broken by this change.

Test Shared\\DateTest had one test where the expected result of converting to a
Unix timestamp exceeds 2**32. Since a Unix timestamp is strictly an int,
that test fails on a 32-bit system. In the discussion regarding recently merged
PR #1870, it was felt that the user base might still be using the functions
that convert to and from a timestamp. So, we should not drop this test, but,
since it cannot succeed on a 32-bit system, I changed it to be skipped
whenever the expected result exceeded PHP_INT_MAX. There are 3 "toTimestamp"
functions within that test. Only one of these had been affected, but I thought
it was a good idea to add additional tests to the others to demonstrate this
condition.

In the course of testing, I also discovered some 32-bit problems with
bitwise and base-conversion functions. I am preparing separate PRs to
deal with those.
2021-03-03 10:52:11 +01:00
..
Gnumeric Stricter visibility 2020-07-19 12:30:31 +09:00
Html Avoid Duplicate Titles When Reading Multiple HTML Files (#1829) 2021-02-27 15:10:04 +01:00
Ods 100% Coverage for Calculation/DateTime (#1870) 2021-02-27 20:43:22 +01:00
Security fixed php8 deprecation warning for libxml_disable_entity_loader() (#1625) 2020-10-08 15:02:14 +02:00
Xls Stricter visibility 2020-07-19 12:30:31 +09:00
Xlsx Fix/chart axis titles (#1760) 2021-01-31 19:13:50 +01:00
Xml Fix Two 32-bit Timestamp Problems, and Minor getFormattedValue Bug (#1891) 2021-03-03 10:52:11 +01:00
CondNumFmtTest.php Update PHP-CS-Fixer rules 2020-05-18 13:49:57 +09:00
CsvContiguousFilter.php Update PHP-CS-Fixer rules 2020-05-18 13:49:57 +09:00
CsvContiguousTest.php Update PHP-CS-Fixer rules 2020-05-18 13:49:57 +09:00
CsvTest.php CSV - Guess Encoding, Handle Null-string Escape (#1717) 2020-12-25 17:47:29 +01:00
OddColumnReadFilter.php Fix column names if read filter calls in XLSX reader skip columns 2018-12-10 20:00:26 +11:00
SheetsXlsxChartTest.php Fix/sheets xlsx chart (#1761) 2021-01-31 18:53:54 +01:00
SlkTest.php Fix for #1612 - SLK Long File Name (#1706) 2020-12-10 22:02:36 +01:00
XlsTest.php Fix for bug #1592 (UPDATED) (#1623) 2020-12-17 19:41:07 +01:00
Xlsx2Test.php Testing - Delete Temp Files When No Longer Needed (#1488) 2020-05-24 20:03:07 +09:00
XlsxTest.php Testing - Delete Temp Files When No Longer Needed (#1488) 2020-05-24 20:03:07 +09:00