-
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.
[2.x] Ensure URL defaults are flushed (#807)
* Ensure URL defaults are flushed * Apply fixes from StyleCI --------- Co-authored-by: StyleCI Bot <[email protected]>
- Loading branch information
1 parent
677320f
commit 9f36957
Showing
1 changed file
with
49 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,49 @@ | ||
<?php | ||
|
||
namespace Laravel\Octane\Tests; | ||
|
||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\URL; | ||
|
||
class UrlTest extends TestCase | ||
{ | ||
public function test_url_defaults_are_flushed() | ||
{ | ||
[$app, $worker, $client] = $this->createOctaneContext([ | ||
Request::create('/b', 'GET'), | ||
Request::create('/a', 'GET'), | ||
Request::create('/b', 'GET'), | ||
]); | ||
|
||
$app['router']->get('a', function () { | ||
URL::defaults(['locale' => 'default']); | ||
|
||
return ['default-parameters' => URL::getDefaultParameters()]; | ||
}); | ||
|
||
$app['router']->get('b/{locale?}', function (?string $locale = null) { | ||
return [ | ||
'locale' => $locale ?: 'none', | ||
'default-parameters' => URL::getDefaultParameters(), | ||
]; | ||
}); | ||
|
||
$worker->run(); | ||
|
||
$this->assertEquals([ | ||
'locale' => 'none', | ||
'default-parameters' => [], | ||
], json_decode($client->responses[0]->getContent(), true)); | ||
|
||
$this->assertEquals([ | ||
'default-parameters' => [ | ||
'locale' => 'default', | ||
], | ||
], json_decode($client->responses[1]->getContent(), true)); | ||
|
||
$this->assertEquals([ | ||
'locale' => 'none', | ||
'default-parameters' => [], | ||
], json_decode($client->responses[0]->getContent(), true)); | ||
} | ||
} |