Skip to content

Commit 9f36957

Browse files
[2.x] Ensure URL defaults are flushed (#807)
* Ensure URL defaults are flushed * Apply fixes from StyleCI --------- Co-authored-by: StyleCI Bot <[email protected]>
1 parent 677320f commit 9f36957

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

tests/UrlTest.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
namespace Laravel\Octane\Tests;
4+
5+
use Illuminate\Http\Request;
6+
use Illuminate\Support\Facades\URL;
7+
8+
class UrlTest extends TestCase
9+
{
10+
public function test_url_defaults_are_flushed()
11+
{
12+
[$app, $worker, $client] = $this->createOctaneContext([
13+
Request::create('/b', 'GET'),
14+
Request::create('/a', 'GET'),
15+
Request::create('/b', 'GET'),
16+
]);
17+
18+
$app['router']->get('a', function () {
19+
URL::defaults(['locale' => 'default']);
20+
21+
return ['default-parameters' => URL::getDefaultParameters()];
22+
});
23+
24+
$app['router']->get('b/{locale?}', function (?string $locale = null) {
25+
return [
26+
'locale' => $locale ?: 'none',
27+
'default-parameters' => URL::getDefaultParameters(),
28+
];
29+
});
30+
31+
$worker->run();
32+
33+
$this->assertEquals([
34+
'locale' => 'none',
35+
'default-parameters' => [],
36+
], json_decode($client->responses[0]->getContent(), true));
37+
38+
$this->assertEquals([
39+
'default-parameters' => [
40+
'locale' => 'default',
41+
],
42+
], json_decode($client->responses[1]->getContent(), true));
43+
44+
$this->assertEquals([
45+
'locale' => 'none',
46+
'default-parameters' => [],
47+
], json_decode($client->responses[0]->getContent(), true));
48+
}
49+
}

0 commit comments

Comments
 (0)