-
Notifications
You must be signed in to change notification settings - Fork 301
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test flushing logger shared context (#514)
* test flushing logger shared context * ignore Laravel 8 * style
- Loading branch information
1 parent
9099946
commit 5efb83d
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |