I'm writing tests for my application and struggling to understand whi Storage class is not building the expected file url.
I'm having thist test that fails on asserting that expected url equals the builded one, so i put an if in my code and dd() stuff out to understand, and that's the result:
IF in my test
if('http://testurl/storage/path/to/file.test' !=
Storage::disk('default_disk')->url('path/to/file.test')){
dd(
config('filesystems.disks.default_disk'),
Storage::disk('default_disk')->url('path/to/file.test'),
);
}
Output
> php vendor/phpunit/phpunit/phpunit
PHPUnit 9.5.2 by Sebastian Bergmann and contributors.
Runtime: PHP 7.4.3
Configuration: C:\Users\silvi\Desktop\RawFile\phpunit.xml
array:3 [
"driver" => "local"
"root" => "root/"
"url" => "http://testurl/storage"
]
"/storage/path/to/file.test"
Script php vendor/phpunit/phpunit/phpunit handling the test event returned with error code 1
Considerations
So in my test the disk configuration is OK, but the Storage class build the wrong url like it is ignoring the url config section.
Don't think this matters, but (obviously) the storage is fake, made with Storage::fake('default_disk'); in the setUp() method.
Laravel
I'm writing tests for a Laravel package, and used "orchestra/testbench": "^6.2" as dev dependancy, so according to their docs it brings up a Laravel 6 application skeleton.
Aucun commentaire:
Enregistrer un commentaire