Skip to content

Commit d00b9f6

Browse files
committed
Test NotFoundWhenProduction
1 parent 140c153 commit d00b9f6

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

tests/NotFoundWhenProductionTest.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
namespace Rakutentech\LaravelRequestDocs\Tests;
4+
5+
use Illuminate\Support\Facades\Route;
6+
use Rakutentech\LaravelRequestDocs\NotFoundWhenProduction;
7+
8+
class NotFoundWhenProductionTest extends TestCase
9+
{
10+
public function testForbiddenInProduction()
11+
{
12+
foreach (['prod', 'production'] as $production) {
13+
app()['env'] = $production;
14+
Route::get('middleware', function () {
15+
return 1;
16+
})->middleware(NotFoundWhenProduction::class);
17+
18+
$this->get('middleware')
19+
->assertStatus(403)
20+
->assertExactJson(['status' => 'forbidden', 'status_code' => 403]);
21+
}
22+
}
23+
24+
public function testMiddleware()
25+
{
26+
Route::get('middleware', function () {
27+
return 1;
28+
})->middleware(NotFoundWhenProduction::class);
29+
30+
$this->get('middleware')
31+
->assertStatus(200)
32+
->assertExactJson([1]);
33+
}
34+
}

0 commit comments

Comments
 (0)