-
Notifications
You must be signed in to change notification settings - Fork 296
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Give New Application to Routes (#899)
* Give New Application to Routes * Tweak
- Loading branch information
Showing
2 changed files
with
51 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
43 changes: 43 additions & 0 deletions
43
tests/Listeners/GiveNewApplicationInstanceToRouterTest.php
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,43 @@ | ||
<?php | ||
|
||
namespace Laravel\Octane\Listeners; | ||
|
||
use Illuminate\Http\Request; | ||
use Illuminate\Routing\Route; | ||
use Laravel\Octane\Tests\TestCase; | ||
|
||
use function Livewire\invade; | ||
|
||
class GiveNewApplicationInstanceToRouterTest extends TestCase | ||
{ | ||
public function test_router_has_new_instance() | ||
{ | ||
[$app, $worker, $client] = $this->createOctaneContext([ | ||
Request::create('/first', 'GET'), | ||
Request::create('/second', 'GET'), | ||
]); | ||
|
||
$app['router']->middleware('web')->get('/first', function () { | ||
$route = collect(app('router')->getRoutes()->getRoutes())->firstWhere(fn (Route $route) => $route->uri() === 'second'); | ||
|
||
return [ | ||
spl_object_id(app()), | ||
spl_object_id(invade($route)->container), | ||
]; | ||
}); | ||
|
||
$app['router']->middleware('web')->get('/second', function () { | ||
$route = collect(app('router')->getRoutes()->getRoutes())->firstWhere(fn (Route $route) => $route->uri() === 'first'); | ||
|
||
return [ | ||
spl_object_id(app()), | ||
spl_object_id(invade($route)->container), | ||
]; | ||
}); | ||
|
||
$worker->run(); | ||
|
||
$this->assertEquals($client->responses[0]->getData()[0], $client->responses[0]->getData()[1]); | ||
$this->assertEquals($client->responses[1]->getData()[0], $client->responses[1]->getData()[1]); | ||
} | ||
} |