Add test for excel document content
This commit is contained in:
parent
c1d0221dcd
commit
50a3c6df90
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace Zoomyboy\TableDocument;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Csv;
|
||||
use PHPUnit\Framework\Assert;
|
||||
|
||||
trait TestsExcelDocuments
|
||||
{
|
||||
|
||||
public function assertExcelContent(string $should, string $content): void
|
||||
{
|
||||
$filename = sys_get_temp_dir() . '/' . str()->uuid()->toString();
|
||||
file_put_contents($filename, $content);
|
||||
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($filename);
|
||||
$writer = new Csv($spreadsheet);
|
||||
$writer->save($filename);
|
||||
$spreadsheet->disconnectWorksheets();
|
||||
$contents = file_get_contents($filename);
|
||||
unlink($filename);
|
||||
Assert::assertStringContainsString($should, $contents);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue