BackgroundErrorTest.php 981 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * Html2Pdf Library - Tests
  4. *
  5. * HTML => PDF converter
  6. * distributed under the OSL-3.0 License
  7. *
  8. * @package Html2pdf
  9. * @author Laurent MINGUET <webmaster@html2pdf.fr>
  10. * @copyright 2023 Laurent MINGUET
  11. */
  12. namespace Spipu\Html2Pdf\Tests\Image;
  13. use Spipu\Html2Pdf\Exception\ImageException;
  14. use Spipu\Html2Pdf\Tests\AbstractTest;
  15. /**
  16. * Class BackgroundErrorTest
  17. */
  18. class BackgroundErrorTest extends AbstractTest
  19. {
  20. /**
  21. * test: The image src is unknown
  22. *
  23. * @return void
  24. */
  25. public function testCase()
  26. {
  27. $this->expectException(ImageException::class);
  28. $image = '/res/wrong.png';
  29. try {
  30. $object = $this->getObject();
  31. $object->writeHTML('<div style="background-image: url('.$image.')">Hello World</div>');
  32. $object->output('test.pdf', 'S');
  33. } catch (ImageException $e) {
  34. $this->assertSame($image, $e->getImage());
  35. throw $e;
  36. }
  37. }
  38. }