Files
PhpSpreadsheet/tests/PhpSpreadsheetTests/Functional/StreamTest.php
T
oleibman bb072d1ca7 Upgrade Dev TCPDF to 6.5 (#3006)
* Upgrade Dev TCPDF to 6.5

Implementation of https://github.com/tecnickcom/TCPDF/pull/467, which is available in just-released Tcpdf 6.5, will improve look of Tcpdf rendering for PhpSpreadsheet. Fix #1164.

One test had been suppressed for Tcpdf, ostensibly because it was not compatible with Php8. As it turns out, the PhpSpreadsheet code which invokes Tcpdf was (harmlessly) incorrect, so the Php8 issue was actually with PhpSpreadsheet, not Tcpdf. That code is corrected, and the test is no longer suppressed.

* Update Change Log

Pick up some earlier changes as well as this one, and deprecations which had been omitted from the 1.24 change log.
2022-08-14 10:57:34 -07:00

56 lines
1.6 KiB
PHP

<?php
namespace PhpOffice\PhpSpreadsheetTests\Functional;
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PHPUnit\Framework\TestCase;
class StreamTest extends TestCase
{
public function providerFormats(): array
{
$providerFormats = [
['Xls'],
['Xlsx'],
['Ods'],
['Csv'],
['Html'],
['Mpdf'],
['Dompdf'],
['Tcpdf'],
];
return $providerFormats;
}
/**
* @dataProvider providerFormats
*/
public function testAllWritersCanWriteToStream(string $format): void
{
$spreadsheet = new Spreadsheet();
$spreadsheet->getActiveSheet()->setCellValue('A1', 'foo');
$writer = IOFactory::createWriter($spreadsheet, $format);
$stream = fopen('php://memory', 'wb+');
$stat = ($stream === false) ? false : fstat($stream);
if ($stream === false || $stat === false) {
self::fail('fopen or fstat failed');
} else {
self::assertSame(0, $stat['size']);
$writer->save($stream);
self::assertIsResource($stream, 'should not close the stream for further usage out of PhpSpreadsheet');
$stat = fstat($stream);
if ($stat === false) {
self::fail('fstat failed');
} else {
self::assertGreaterThan(0, $stat['size'], 'something should have been written to the stream');
}
self::assertGreaterThan(0, ftell($stream), 'should not be rewinded, because not all streams support it');
}
}
}