timacdonald / log-fake

A drop in fake logger for testing with the Laravel framework.
MIT License
404 stars 31 forks source link

Error: Call to undefined method TiMacDonald\Log\ChannelFake::flushSharedContext() #52

Open luke83 opened 3 months ago

luke83 commented 3 months ago

When running in tests something like:

LogFake::bind();

$this->artisan('queue:work database --queue=default --once');

Log::assertNothingLogged();

i got:

Error: Call to undefined method TiMacDonald\Log\ChannelFake::flushSharedContext()
./vendor/timacdonald/log-fake/src/LogFake.php:222
./vendor/laravel/framework/src/Illuminate/Queue/QueueServiceProvider.php:201

it seems related to this feature: https://github.com/laravel/framework/commit/864ef6a3248359b21fd804137f1f0421630415d7

As workaround i added this to TiMacDonald\Log\LogFake:

   /**
     * Flush the shared context.
     *
     * @return array
     */
    public function flushSharedContext()
    {
        $this->sharedContext = [];

        return $this;
    }
epic-64 commented 1 month ago

Having the same issue, this prevents us from upgrading to Laravel 10, which calls $app['log']->flushSharedContext(); within QueueServiceProvider::registerWorker()