Remove tests that include tcPDF and DomPDF libraries when running against PHP8, because neither library is yet PHP8-ready

This commit is contained in:
MarkBaker 2020-10-09 14:31:16 +02:00
parent 87a909aaf8
commit ee13533db3
4 changed files with 40 additions and 17 deletions

View File

@ -12,10 +12,12 @@ $spreadsheet = $reader->load(__DIR__ . '/../templates/26template.xlsx');
// at this point, we could do some manipulations with the template, but we skip this step
$helper->write($spreadsheet, __FILE__, ['Xlsx', 'Xls', 'Html']);
// Export to PDF (.pdf)
$helper->log('Write to PDF format');
IOFactory::registerWriter('Pdf', \PhpOffice\PhpSpreadsheet\Writer\Pdf\Dompdf::class);
$helper->write($spreadsheet, __FILE__, ['Pdf']);
if (\PHP_VERSION_ID < 80000) {
// Export to PDF (.pdf)
$helper->log('Write to PDF format');
IOFactory::registerWriter('Pdf', \PhpOffice\PhpSpreadsheet\Writer\Pdf\Dompdf::class);
$helper->write($spreadsheet, __FILE__, ['Pdf']);
}
// Remove first two rows with field headers before exporting to CSV
$helper->log('Removing first two heading rows for CSV export');

View File

@ -32,11 +32,13 @@ $spreadsheet->getActiveSheet()->setShowGridLines(false);
$helper->log('Set orientation to landscape');
$spreadsheet->getActiveSheet()->getPageSetup()->setOrientation(PageSetup::ORIENTATION_LANDSCAPE);
$helper->log('Write to Dompdf');
$writer = new Dompdf($spreadsheet);
$filename = $helper->getFileName('21b_Pdf_dompdf.xlsx', 'pdf');
$writer->setEditHtmlCallback('replaceBody');
$writer->save($filename);
if (\PHP_VERSION_ID < 80000) {
$helper->log('Write to Dompdf');
$writer = new Dompdf($spreadsheet);
$filename = $helper->getFileName('21b_Pdf_dompdf.xlsx', 'pdf');
$writer->setEditHtmlCallback('replaceBody');
$writer->save($filename);
}
$helper->log('Write to Mpdf');
$writer = new Mpdf($spreadsheet);
@ -44,8 +46,10 @@ $filename = $helper->getFileName('21b_Pdf_mpdf.xlsx', 'pdf');
$writer->setEditHtmlCallback('replaceBody');
$writer->save($filename);
$helper->log('Write to Tcpdf');
$writer = new Tcpdf($spreadsheet);
$filename = $helper->getFileName('21b_Pdf_tcpdf.xlsx', 'pdf');
$writer->setEditHtmlCallback('replaceBody');
$writer->save($filename);
if (\PHP_VERSION_ID < 80000) {
$helper->log('Write to Tcpdf');
$writer = new Tcpdf($spreadsheet);
$filename = $helper->getFileName('21b_Pdf_tcpdf.xlsx', 'pdf');
$writer->setEditHtmlCallback('replaceBody');
$writer->save($filename);
}

View File

@ -10,16 +10,23 @@ class StreamTest extends TestCase
{
public function providerFormats(): array
{
return [
$providerFormats = [
['Xls'],
['Xlsx'],
['Ods'],
['Csv'],
['Html'],
['Tcpdf'],
['Dompdf'],
['Mpdf'],
];
if (\PHP_VERSION_ID < 80000) {
$providerFormats = array_merge(
$providerFormats,
[['Tcpdf'],['Dompdf']]
);
}
return $providerFormats;
}
/**

View File

@ -31,6 +31,16 @@ class SampleTest extends TestCase
'Chart/32_Chart_read_write_PDF.php', // Unfortunately JpGraph is not up to date for latest PHP and raise many warnings
'Chart/32_Chart_read_write_HTML.php', // idem
];
// TCPDF and DomPDF libraries don't support PHP8 yet
if (\PHP_VERSION_ID >= 80000) {
$skipped = array_merge(
$skipped,
[
'Pdf/21_Pdf_Domdf.php',
'Pdf/21_Pdf_TCPDF.php',
]
);
}
// Unfortunately some tests are too long be ran with code-coverage
// analysis on Travis, so we need to exclude them