Skip to content

Commit 5efb83d

Browse files
authored
test flushing logger shared context (#514)
* test flushing logger shared context * ignore Laravel 8 * style
1 parent 9099946 commit 5efb83d

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace Laravel\Octane\Listeners;
4+
5+
use Illuminate\Foundation\Application;
6+
use Illuminate\Http\Request;
7+
use Laravel\Octane\Tests\TestCase;
8+
9+
class FlushLogContextTest extends TestCase
10+
{
11+
public function test_shared_context_is_flushed()
12+
{
13+
if (version_compare(Application::VERSION, '9.0.0', '<')) {
14+
$this->markTestSkipped('Shared context is only supported in Laravel 9+');
15+
}
16+
17+
[$app, $worker, $client] = $this->createOctaneContext([
18+
Request::create('/', 'GET'),
19+
]);
20+
$app['router']->middleware('web')->get('/', function () {
21+
// ..
22+
});
23+
$log = $app['log'];
24+
$log->shareContext(['shared' => 'context']);
25+
26+
$this->assertSame(['shared' => 'context'], $log->sharedContext());
27+
28+
$worker->run();
29+
30+
$this->assertSame([], $log->sharedContext());
31+
}
32+
}

0 commit comments

Comments
 (0)