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.
Update
I tried removing the Storage::fake('default_disk'); and the test passed, having the Storage correctly using my configs.
As gbalduzzi said, if the storage is fake it ignores whatever is in my configs.
When you use fake() to create a disk, Laravel will not consider anymore your configuration from the usual file config/filesystems.php.
It will create a custom, fake, disk.
To solve your problem, you should use the actual disk without creating it using fake(). This is not ideal though, because running your tests will actually add files into the selected storage.
The fact is, you should not be testing that the Storage facades builds the proper url. Your tests should focus on the code written by YOU. It is laravel job to properly test their interfaces/methods/facades.
After update from laravel 7 to version 8 all test failing with same error:
Illuminate\Database\QueryException: SQLSTATE[HY000]: General error: 1 no such index: IDX_426EF39216FE72E1 (SQL: DROP INDEX IDX_426EF39216FE72E1)
I am also using legacy-factories package for old factories approach
I finally solve this problem using laravel shift because there is lot of things to be done after upgrade and list in my case is huge because I use custom namespace and I must handle that in AppServiceProvider. Shift also refactor all of mine factories that I have
when I am trying to use the stripe test key.
Laravel 5.7
php 7.2
Your test product was empty. create a test product first switch viewing test data
on your stripe dashboard
Dusk is providing individual logs for tests that returned failures / warnings in the console, but what I'm really after is one big log file or report that lists the pass/fail status of each test in my Dusk script.
Can anyone suggest a way to go about this? I can't find an answer anywhere but it seems like it should be a relatively common thing to need so I'm sure I've overlooked something.
You can use PHPUnit's logging:
php artisan dusk --log-junit junit.log
php artisan dusk --log-teamcity teamcity.log
Im building a project in laravel 3 and wondering how you can debug Fluent Query Builder ie. get the error message or the produced SQL in order to see what im doing wrong
If you enable the profiler in Laravel 3 it will show you the executed queries once the page has loaded. You can enable it by setting the profiler option to true in application/config/application.php