-
Notifications
You must be signed in to change notification settings - Fork 341
Expand file tree
/
Copy pathUrlGeneratorSandboxTest.php
More file actions
49 lines (39 loc) · 1.42 KB
/
UrlGeneratorSandboxTest.php
File metadata and controls
49 lines (39 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
namespace Laravel\Octane\Tests;
use Illuminate\Foundation\Application;
use Illuminate\Http\Request;
class UrlGeneratorSandboxTest extends TestCase
{
public function test_url_is_reset_between_requests()
{
[$app, $worker, $client] = $this->createOctaneContext([
Request::create('/first', 'GET'),
Request::create('/second', 'GET'),
]);
$app['url']->defaults(['param' => 'original']);
$app['url']->forceRootUrl('http://original');
$app['router']->get('/first', function (Application $app) {
$app['url']->defaults(['param' => 'changed']);
$app['url']->forceRootUrl('http://changed');
return [
'default' => $app['url']->getDefaultParameters(),
'url' => $app['url']->to('/'),
];
});
$app['router']->get('/second', function (Application $app) {
return [
'default' => $app['url']->getDefaultParameters(),
'url' => $app['url']->to('/'),
];
});
$worker->run();
$this->assertEquals([
'default' => ['param' => 'changed'],
'url' => 'http://changed',
], $client->responses[0]->getData(true));
$this->assertEquals([
'default' => ['param' => 'original'],
'url' => 'http://original',
], $client->responses[1]->getData(true));
}
}