Problem/Motivation

No tests

Proposed resolution

Add following tests:

  • testDefaultRenderingProducesValidSettingsJson — render a node with 2 images through the default-settings formatter, assert the output contains the owl-slider-wrapper class and a data-settings="..." attribute whose value is valid JSON.
  • testImageLinkToFileDoesNotThrow / testImageLinkToContentDoesNotThrow — render with image_link set to 'file' / 'content' and assert no exception and the expected <a href=...> markup appears (this exercises OwlCarouselFieldFormatter::viewElements()'s file_url_generator/toUrl() branches, src/Plugin/Field/FieldFormatter/OwlCarouselFieldFormatter.php:259-270).
  • testRenderedSettingsNeverContainNavTextOrUnknownKeys: decode the rendered data-settings JSON and assert every key is one of OwlCarouselGlobal::defaultSettings()'s keys (minus image_style/image_link, which are stripped) plus responsive; explicitly assertArrayNotHasKey('navText', $decoded). This encodes the invariant the XSS fix in js/owlcarousel.js depends on — if a future change ever adds a free-text setting emitted into data-settings, this test fails as a signal that it also needs client-side escaping

Comments

ipwa created an issue. See original summary.

  • ipwa committed 8a843368 on 3.1.x
    task: #3613551 Add PHPUnit test suite
    
    By: ipwa
    
ipwa’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.