Skip to content
Snippets Groups Projects

Test if processor if set in config

Open Ludovic Favre requested to merge issue/avif-3241146:3241146-failed-to-load into 1.0.x
2 unresolved threads

Closes #3241146

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
92 92 '#responsive_image_style_id' => $this->imageStyle->id(),
93 93 ];
94 94
95 $this->container->get('config.factory')->getEditable('avif.settings')->set('processor', 'imagemagick')->save();
96
  • Comment on lines +95 to +96

    We should adjust this test to use a data provider with the image processor. There is a test module with a dummy processor we can use instead of imagemagick. I think we just need two options, NULL and 'avif_test'. The data provider should also specify the expected number of avif and jpeg images. That way we can test that there is no avif in the markup when the processor is NULL and there is one avif in the markup when the processor is 'avif_test'.

  • Please register or sign in to reply
  • 31 31 function avif_preprocess_responsive_image(&$variables) {
    32 32 $avif_sources = [];
    33 33
    34 if (!isset($variables['sources'])) {
    34 $avifProcessor = \Drupal::configFactory()->getEditable('avif.settings')->get('processor');
    35
    36 if (!isset($variables['sources']) || !$avifProcessor) {
    • Comment on lines -34 to +36

      I think we need to test more than just the config value is not empty. We should call \Drupal::service('plugin.manager.avif_processor')->getDefinition($pluginId) and ensure it's an instanceof AvifProcessorInterface. That will ensure we don't have a bogus config value, e.g. if you uninstall a module that was previously providing the processor.

      In fact we should add another case to the data provider for a random string in the config value.

    • igor mashevskyi changed this line in version 6 of the diff

      changed this line in version 6 of the diff

    • Please register or sign in to reply
  • nterbogt added 2 commits

    added 2 commits

    • 45c83fac - 1 commit from branch project:1.0.x
    • 79126997 - Test if processor if set in config

    Compare with previous version

  • igor mashevskyi added 1 commit

    added 1 commit

    • 5307edc1 - Issue #3241146: Corrected check if avif processor exists and corrected test.

    Compare with previous version

  • Please register or sign in to reply
    Loading