Skip to content

Commit

Permalink
[2.x] Ensure URL defaults are flushed (#807)
Browse files Browse the repository at this point in the history
* Ensure URL defaults are flushed

* Apply fixes from StyleCI

---------

Co-authored-by: StyleCI Bot <[email protected]>
  • Loading branch information
nunomaduro and StyleCIBot authored Jan 8, 2024
1 parent 677320f commit 9f36957
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions tests/UrlTest.php
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));
}
}

0 comments on commit 9f36957

Please sign in to comment.