SVG Image Field: FileValidationTest.php:85 fails on invalid_svg1.svg

Created on 18 January 2023, almost 2 years ago

Problem/Motivation

I've just enabled tests on the 2.2.x-dev branch and issues here:

https://www.drupal.org/node/2863622/qa

And we got an immediate failure on the first run:

https://www.drupal.org/pift-ci-job/2570839

The failure text is:

Testing Drupal\Tests\svg_image_field\Unit\FileValidationTest
F                                                                   1 / 1 (100%)

Time: 00:00.820, Memory: 6.00 MB

There was 1 failure:

1) Drupal\Tests\svg_image_field\Unit\FileValidationTest::testFileValidation
Check that invalid_svg1.svg is invalid
Failed asserting that false matches expected true.

/var/www/html/vendor/phpunit/phpunit/src/Framework/Constraint/Equality/IsEqual.php:96
/var/www/html/modules/contrib/svg_image_field/tests/src/Unit/FileValidationTest.php:85
/var/www/html/vendor/phpunit/phpunit/src/Framework/TestResult.php:728

FAILURES!
Tests: 1, Assertions: 6, Failures: 1.

Upon investigation, it appears that the file invalid_svg1.svg provided with this module's tests may not in fact be an invalid SVG.

I tested rendering the file in a browser, with a QuickLook plugin on my Mac, and with a Visual Studio Code plugin, and they all correctly rendered the SVG.

I further tested it on https://validator.nu/ and while it did come back with a few errors, I dont think they would preclude our function svg_image_field_validate_mime_type from detecting the mime type.

Proposed resolution

Currently the validity test uses only svg_image_field_validate_mime_type, to test whether an SVG is valid or not.

We must determine what aspect of invalid_svg1.svg should have made it invalid, and determine the best approach for solving the issue. I'm not sure as yet if this means changing the test, or changing the svg file.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

2.2

Component

Code

Created by

🇪🇨Ecuador jwilson3

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Status changed to Needs review almost 2 years ago
  • Status changed to Fixed almost 2 years ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024