Skip to content

Commit

Permalink
[1.x] Add nested controller route grouping (#433)
Browse files Browse the repository at this point in the history
* Add nested controller route grouping

* linting
  • Loading branch information
timacdonald authored Dec 17, 2024
1 parent 934b2a7 commit ac3b8e5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Support/RedisAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function xadd(string $key, array $dictionary): string|Pipeline|PhpRedis|R
*/
public function xrange(string $key, string $start, string $end, ?int $count = null): array
{
return collect($this->handle([ // @phpstan-ignore return.type, argument.templateType, argument.templateType
return collect($this->handle([ // @phpstan-ignore argument.templateType, argument.templateType
'XRANGE',
$this->config->get('database.redis.options.prefix').$key,
$start,
Expand Down
24 changes: 24 additions & 0 deletions tests/Feature/Recorders/SlowRequestsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,30 @@
Pulse::ignore(fn () => expect(DB::table('pulse_values')->count())->toBe(0));
});

it('handles controller nested route groups', function () {
Config::set('pulse.recorders.'.SlowRequests::class.'.threshold', 0);

Route::controller(MyController::class)->group(function () {
Route::get('index', 'index')->name('test')->withoutMiddleware('auth:admin');
})->withoutMiddleware('auth');

$response = get('/index');
Pulse::stopRecording();

$response->assertContent('ok');
$entries = DB::table('pulse_entries')->get();
expect($entries)->toHaveCount(1);
expect($entries[0]->key)->toBe(json_encode(['GET', '/index', 'MyController@index']));
});

class MyController
{
public function index()
{
return 'ok';
}
}

class ExceptionThrowingRecorder
{
public function register(callable $record, Application $app): void
Expand Down

0 comments on commit ac3b8e5

Please sign in to comment.