44 lines
1.2 KiB
PHP
44 lines
1.2 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
|
|
{
|
|
return [
|
|
['Xls'],
|
|
['Xlsx'],
|
|
['Ods'],
|
|
['Csv'],
|
|
['Html'],
|
|
['Tcpdf'],
|
|
['Dompdf'],
|
|
['Mpdf'],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @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+');
|
|
self::assertSame(0, fstat($stream)['size']);
|
|
|
|
$writer->save($stream);
|
|
|
|
self::assertIsResource($stream, 'should not close the stream for further usage out of PhpSpreadsheet');
|
|
self::assertGreaterThan(0, fstat($stream)['size'], 'something should have been written to the stream');
|
|
self::assertGreaterThan(0, ftell($stream), 'should not be rewinded, because not all streams support it');
|
|
}
|
|
}
|