Skip to content

Commit

Permalink
test flushing logger shared context (#514)
Browse files Browse the repository at this point in the history
* test flushing logger shared context

* ignore Laravel 8

* style
  • Loading branch information
timacdonald authored May 18, 2022
1 parent 9099946 commit 5efb83d
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/Listeners/FlushLogContextTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace Laravel\Octane\Listeners;

use Illuminate\Foundation\Application;
use Illuminate\Http\Request;
use Laravel\Octane\Tests\TestCase;

class FlushLogContextTest extends TestCase
{
public function test_shared_context_is_flushed()
{
if (version_compare(Application::VERSION, '9.0.0', '<')) {
$this->markTestSkipped('Shared context is only supported in Laravel 9+');
}

[$app, $worker, $client] = $this->createOctaneContext([
Request::create('/', 'GET'),
]);
$app['router']->middleware('web')->get('/', function () {
// ..
});
$log = $app['log'];
$log->shareContext(['shared' => 'context']);

$this->assertSame(['shared' => 'context'], $log->sharedContext());

$worker->run();

$this->assertSame([], $log->sharedContext());
}
}

0 comments on commit 5efb83d

Please sign in to comment.