From d8e471b235f5cbed927dc437f677c817810c695f Mon Sep 17 00:00:00 2001 From: Lukas Gaechter Date: Tue, 27 Aug 2024 14:22:31 +0200 Subject: [PATCH] fix: Add test --- tests/test-svg.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/test-svg.php b/tests/test-svg.php index d8439fd..1c364b2 100644 --- a/tests/test-svg.php +++ b/tests/test-svg.php @@ -15,6 +15,25 @@ public function test_get_timber_image_full_with_svg() { $this->assertEquals( $image, $result ); } + /** + * Tests whether we still get the image src without an error, even if the + * SVG file is missing. + * + * @since 2.1.0 + */ + public function test_get_timber_image_full_with_svg_inexistent() { + $attachment = $this->create_image( [ 'file' => 'sveegee.svg' ] ); + + if (file_exists($attachment->file_loc())) { + unlink($attachment->file_loc()); + } + + $result = get_timber_image( $attachment, 'full' ); + $image = ' src="' . $this->get_upload_url() . '/sveegee.svg" alt=""'; + + $this->assertEquals( $image, $result ); + } + /** * Tests whether we get the full src of an SVG with size large. *