I’m currently working on a unit test for file uploads. The test is functioning correctly, but there’s an issue when the upload occurs: VichUploader automatically renames the file from logo.png to something like logo-66f5060e...png. This causes the test to fail on following runs, as logo.png no longer exists.
I’ve tried creating a custom Vich namer to prevent this behavior, but encountered the following error:
The "App\Namer\TestNamer.media" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead.
Support Question
I’m currently working on a unit test for file uploads. The test is functioning correctly, but there’s an issue when the upload occurs: VichUploader automatically renames the file from logo.png to something like logo-66f5060e...png. This causes the test to fail on following runs, as logo.png no longer exists. I’ve tried creating a custom Vich namer to prevent this behavior, but encountered the following error:
The "App\Namer\TestNamer.media" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead.
Is there any known solution for this?
Unit Test:
vich settings:
I also tried to use property namer. But couldn't find name property
vich settings: when@test: vich_uploader: db_driver: orm metadata: type: attribute mappings: media: uri_prefix: /media upload_destination: '%kernel.project_dir%/tests/Api/Media/Fixtures' namer: service: Vich\UploaderBundle\Naming\PropertyNamer options: { property: 'name' }