mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-30 00:48:01 +00:00
39df9c3bcc
* Fix Some Pdf Problems Fix #1747. No support for text rotation in Pdf. That issue actually has a decent workaround, but PhpSpreadsheet should handle it on its own. Mpdf requires the proprietary text-rotate css attribute; Html and Dompdf will use the CSS3 attribute transform:rotate. Fix #1713. Some paper-size values in PhpSpreadsheet are strings, some are 2-element float arrays. Dompdf accepts strings or 4-element float arrays, where the first 2 elements are always 0. Convert the PhpSpreadsheet array accordingly before passing it to Dompdf. Some tests had been disabled when Dompdf and Tcpdf were slow to achieve PHP8 compliance. They achieved it some time ago. Re-enable the tests. * Remove Tcpdf From One Test No problem with the other tests I added it in for.
62 lines
1.8 KiB
PHP
62 lines
1.8 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'],
|
|
];
|
|
|
|
if (\PHP_VERSION_ID < 80000) {
|
|
$providerFormats = array_merge(
|
|
$providerFormats,
|
|
[['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');
|
|
}
|
|
}
|
|
}
|