Skip to content

Commit 07db692

Browse files
committed
Disable
1 parent b8ddd17 commit 07db692

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

src/Frontier.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ class Frontier
1111
{
1212
public static function add(array $config): void
1313
{
14+
if (empty($config['enabled'])) {
15+
return;
16+
}
17+
1418
match ($config['type']) {
1519
'http' => self::http($config),
1620
'proxy' => self::proxy($config),

tests/Unit/DisableTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Dex\Laravel\Frontier\Frontier;
6+
use Illuminate\Support\Facades\Http;
7+
8+
test('assert not found when Frontier is disabled', function () {
9+
Frontier::add([
10+
'enabled' => false,
11+
'type' => 'proxy',
12+
'host' => 'frontier.test',
13+
'rules' => [
14+
'/disabled::exact',
15+
],
16+
]);
17+
18+
Http::fake([
19+
'frontier.test/disabled' => Http::response('Frontier is disabled'),
20+
]);
21+
22+
$this->get('disabled')
23+
->assertNotFound();
24+
});

0 commit comments

Comments
 (0)