mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-15 12:36:32 +00:00
e8033b8453
Issue3982Test mysteriously ran into memory problems when we migrated from Phpunit 9 to 10. It wasn't all that critical a test, so it has been disabled ever since. I finally had some time to research, and the problem is unquestionably with Phpunit's `assertCount` test - it doesn't like something about our array. However, we can easily redo that test by using Php's native `count` function, and testing that result with `assertSame`. I have not yet succeeded at simplifying the test to a state where I am willing to report the bug, but I'll keep trying. In the meantime, the test is recoded, and can now be run successfully. No source code changes.
56 lines
1.9 KiB
PHP
56 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Reader\Xlsx;
|
|
|
|
use PhpOffice\PhpSpreadsheet\IOFactory;
|
|
use PhpOffice\PhpSpreadsheet\Reader\IReader;
|
|
use PhpOffice\PhpSpreadsheet\Reader\Xlsx as XlsxReader;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class Issue3982Test extends TestCase
|
|
{
|
|
private static string $testbook = 'tests/data/Reader/XLSX/issue.3982.xlsx';
|
|
|
|
/**
|
|
* This routine comes nowhere close to out-of-memory (uses 45MB).
|
|
* Yet it goes out of memory in PhpUnit 10 (uses 2GB!).
|
|
* Works fine in PhpUnit9-.
|
|
* We can mitigate the problem by changing entirely-null rows
|
|
* to empty rows in rangeToArrayYieldRows. (uses 455MB).
|
|
* That's a breaking change, but might be worth considering.
|
|
*
|
|
* Aha! I have narrowed the problem to self::assertCount,
|
|
* which has a ready substitution. I will report the problem
|
|
* to Phpunit if I can come up with a simpler example.
|
|
*/
|
|
public function testLoadAllRows(): void
|
|
{
|
|
$spreadsheet = IOFactory::load(self::$testbook);
|
|
$sheet = $spreadsheet->getActiveSheet();
|
|
$data = $sheet->toArray(null, true, false, true);
|
|
$count = count($data);
|
|
self::assertSame(1_048_576, $count);
|
|
$spreadsheet->disconnectWorksheets();
|
|
}
|
|
|
|
public function testIgnoreCellsWithNoRows(): void
|
|
{
|
|
$spreadsheet = IOFactory::load(self::$testbook, IReader::IGNORE_ROWS_WITH_NO_CELLS);
|
|
$sheet = $spreadsheet->getActiveSheet();
|
|
$data = $sheet->toArray(null, true, false, true);
|
|
self::assertSame([1, 2, 3, 4, 5, 6], array_keys($data));
|
|
$spreadsheet->disconnectWorksheets();
|
|
}
|
|
|
|
public function testDefaultSetting(): void
|
|
{
|
|
$reader = new XlsxReader();
|
|
self::assertFalse($reader->getIgnoreRowsWithNoCells());
|
|
self::assertFalse($reader->getReadDataOnly());
|
|
self::assertFalse($reader->getIncludeCharts());
|
|
self::assertTrue($reader->getReadEmptyCells());
|
|
}
|
|
}
|