From 87a909aaf8987166541d95b702b05a16fd7e5163 Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Fri, 9 Oct 2020 12:58:33 +0200 Subject: [PATCH] Use ZipArchive methods as zip_* functions are deprecated in PHP8 --- .../Writer/Xlsx/UnparsedDataCloneTest.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tests/PhpSpreadsheetTests/Writer/Xlsx/UnparsedDataCloneTest.php b/tests/PhpSpreadsheetTests/Writer/Xlsx/UnparsedDataCloneTest.php index d2afb423..2eeaef9d 100644 --- a/tests/PhpSpreadsheetTests/Writer/Xlsx/UnparsedDataCloneTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Xlsx/UnparsedDataCloneTest.php @@ -34,19 +34,20 @@ class UnparsedDataCloneTest extends TestCase $writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet); $writer->save($resultFilename); $dupname = 'Unable to open saved file'; - $zip = zip_open($resultFilename); - if (is_resource($zip)) { + + $zip = new \ZipArchive(); + if ($zip->open($resultFilename) !== false) { $names = []; $dupname = ''; - while ($zip_entry = zip_read($zip)) { - $zipname = zip_entry_name($zip_entry); - if (in_array($zipname, $names)) { - $dupname .= "$zipname,"; + for ($index = 0; $index < $zip->numFiles; ++$index) { + $filename = $zip->getNameIndex($index); + if (in_array($filename, $names)) { + $dupname .= "$filename,"; } else { - $names[] = $zipname; + $names[] = $filename; } } - zip_close($zip); + $zip->close(); } unlink($resultFilename); self::assertEquals('', $dupname);