liip / LiipImagineBundle

Symfony Bundle to assist in image manipulation using the imagine library
http://liip.ch
MIT License
1.66k stars 378 forks source link

Flysystem in-memory test support #1324

Closed angelomelonas closed 3 years ago

angelomelonas commented 3 years ago

Is your feature request related to a problem? Please describe. We use the OneupFlysystemBundle with the in-memory configuration when testing uploading images (using VichUploaderBundle). I have now added the resizing of images directly after upload, but I would like this to also happen in-memory like the rest of our image upload tests.

Describe the solution you'd like Does support for this exist already? If so, does anyone have an example of how they have achieved this?

Describe alternatives you've considered An alternative solution would be to disable the resizing of images during testing, but of course this is not ideal.

Additional context My config for the above is as follows:

# config/packages/vich_uploader.yaml
vich_uploader:
    db_driver: orm
    storage: flysystem

    mappings:
        images:
            uri_prefix: /uploaded/images
            upload_destination: images_storage
            namer: acme\Naming\UuidNamer
# config/packages/liip_imagine.yaml
liip_imagine:
  # valid drivers options include "gd" or "gmagick" or "imagick"
  driver: "gd"
  resolvers:
    default:
      web_path: ~
  loaders:
    images_storage:
      flysystem:
        filesystem_service: oneup_flysystem.images_storage_filesystem

    filter_sets:
       ...

Flysystem config:

# config/packages/oneup_flysystem.yaml
oneup_flysystem:
    adapters:
        images_adapter:
            local:
                directory: '%kernel.project_dir%/public/uploaded/images'
    filesystems:
        images_storage:
            adapter: images_adapter
            mount: images_storage

And in the in-memory config:

oneup_flysystem:
    adapters:
        images_adapter:
            custom:
                service: acme\Infrastructure\Flysystem\VichMemoryAdapter
angelomelonas commented 3 years ago

Solved this with better configuration.

cirdan commented 3 years ago

@angelomelonas : can you provide some insights about the solution you found ? We are in the same situation, but no way to have tests that pass :-(

Thank you !