- Issue created by @dydave
- 9b65e2f5 committed on 2.1.x
Issue #3413306 by DYdave: Automated testing: Refactored Tests expected...
- 9b65e2f5 committed on 2.1.x
- 8cbf97af committed on 2.1.x
Issue #3413306 by DYdave: Automated testing: Minor fix of Test '...
- 8cbf97af committed on 2.1.x
- Status changed to Fixed
10 months ago 12:37am 9 January 2024 - 🇫🇷France dydave
Quick follow-up on this issue:
Replaced the call:$this->assertEquals($rendered_output, new FormattableMarkup($expected_result[$drupal_version][$show_link], ["@file_url" => $file_url]));
with
$this->assertSame($rendered_output, (string) new FormattableMarkup($expected_result[$drupal_version][$show_link], ["@file_url" => $file_url]));
casting the second argument to string.
After making this change I noticed a test for the
responsive_image_link_formatter
started failing with error:1) Drupal\Tests\responsive_image_link_formatter\Functional\ResponsiveImageLinkFormatterTest::testResponsiveImageLinkFormatterWrappedImage Failed asserting that two strings are identical. --- Expected +++ Actual @@ @@ -'<a href="http://example.com"><img alt="" loading="lazy" src="/sites/simpletest/76904023/files/2024-01/image-test.png" width="40" height="20" /></a>' +'<a href="http://example.com"><img alt="" src="/sites/simpletest/76904023/files/2024-01/image-test.png" width="40" height="20" loading="lazy" /></a>'
It appeared the generated markup for D10 had changed and the position of the attribute
loading="lazy"
had moved.So the tests expected HTML results had to be refactored to work with the different versions of Core supported by the module:
Currently, for theresponsive_image_link_formatter
:- Drupal core < 10.1:
<img alt="" src="/web/sites/simpletest/48924654/files/2024-01/image-test.png" width="40" height="20" loading="lazy" />
- Drupal core >= 10.1:
<img alt="" loading="lazy" src="/web/sites/simpletest/48924654/files/2024-01/image-test.png" width="40" height="20" />
Forimage_link_formatter
:- Drupal core < 9.4:
<img src="/web/sites/simpletest/48924654/files/2024-01/image-test.png" width="40" height="20" alt="" loading="lazy" />
- Drupal core >= 9.4:
<img loading="lazy" src="/web/sites/simpletest/48924654/files/2024-01/image-test.png" width="40" height="20" alt="" />
Added a minor change to the documentation.The changes have been committed directly to the 2.1.x branch which seems to still be passing all tests, see:
https://git.drupalcode.org/project/image_link_formatter/-/pipelines/73888We're still getting PHPStan warnings but at least all PHPUnit tests pass.
Feel free to let us know if you have any questions or concerns on any aspects of these changes or the ticket in general, we would surely be happy to help.
Thanks in advance! - Drupal core < 10.1:
Automatically closed - issue fixed for 2 weeks with no activity.