jobayer-mojumder's avatar

Storage::fake('public) throwing error "Too few arguments"

According to the title, when I try to use Storage::fake('public'), it shows an error for passing two arguments, unfortunately.

Error:

There was 1 error:

1) Tests\Integration\Services\Feeds\StorageTest::it_checks_files_in_fake_storage
ArgumentCountError: Too few arguments to function Illuminate\Filesystem\FilesystemManager::createLocalDriver(), 1 passed in /var/www/application/web/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php on line 358 and exactly 2 expected

My code:


namespace Tests\Integration\Services\Feeds;

use Tests\TestCase;
use Illuminate\Support\Facades\Storage;

class StorageTest extends TestCase
{
    public function setUp(): void
    {
        parent::setUp();
    }

    /** @test */
    public function it_checks_files_in_fake_storage(): void
    {
        Storage::fake('public');

        Storage::delete('public/uploads/users/default-avatar.jpg');

        Storage::disk('public')->assertMissing('uploads/users/default-avatar.jpg');
    }
}

I haven't changed any configuration related to filesystems. I am using the default configuration from the Laravel installation. Any thoughts on how I could tackle this issue?

0 likes
2 replies
Nakov's avatar

Which version of the framework are you using?

php artisan --version

you can try explicitly passing a second argument which is an empty array. But this is just to bypass the issue, an update of the framework should fix it too I think, I tried on 11.8.0 all good.

Storage::fake('public', []);
1 like
jobayer-mojumder's avatar

I am using Laravel 11.23.0. I tried to pass the second argument but still got the error.

I updated the Laravel version (11.26.0), and it works fine. Thanks

Please or to participate in this conversation.