| Conditions | 1 |
| Paths | 1 |
| Total Lines | 25 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | public function testWrite(): void |
||
| 16 | { |
||
| 17 | global $container; |
||
| 18 | |||
| 19 | /** @var Zip $writer */ |
||
| 20 | $writer = $container->get(Zip::class); |
||
| 21 | $tempFile = tempnam('data/tmp/', 'zip'); |
||
| 22 | |||
| 23 | $this->export($writer, $tempFile); |
||
| 24 | |||
| 25 | // Assert that it is a valid ZIP file to prevent PhpSpreadsheet from hanging |
||
| 26 | $zip = new ZipArchive(); |
||
| 27 | $res = $zip->open($tempFile, ZipArchive::CHECKCONS); |
||
| 28 | self::assertTrue($res, 'exported file should be a valid ZIP file'); |
||
| 29 | |||
| 30 | self::assertNotFalse($zip->getFromName('111.html'), 'should contain an image'); |
||
| 31 | self::assertNotFalse($zip->getFromName('222.html'), 'should contain an image'); |
||
| 32 | self::assertNotFalse($zip->getFromName('222.jpg'), 'should contain an image'); |
||
| 33 | |||
| 34 | $actual = $zip->getFromName('222.html'); |
||
| 35 | self::assertStringContainsString('test with stuff', $actual); |
||
| 36 | self::assertStringContainsString('expanded', $actual); |
||
| 37 | |||
| 38 | $zip->close(); |
||
| 39 | unlink($tempFile); |
||
| 40 | } |
||
| 42 |