-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix undefined variable $response in Middleware (#137)
* Fix undefined variable $response in Middleware when usin withoutExceptionHandling * fix cs
- Loading branch information
1 parent
ea4ac27
commit 57d8f7a
Showing
2 changed files
with
62 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
namespace Spectator\Tests; | ||
|
||
use ErrorException; | ||
use Illuminate\Support\Facades\Config; | ||
use Illuminate\Support\Facades\Route; | ||
use Illuminate\Validation\ValidationException; | ||
|
@@ -37,6 +38,46 @@ public function test_asserts_invalid_path() | |
->assertValidationMessage('Path [GET /invalid] not found in spec.'); | ||
} | ||
|
||
public function test_fails_asserts_invalid_path() | ||
{ | ||
$this->expectException(ErrorException::class); | ||
$this->expectExceptionMessage('Path [GET /invalid] not found in spec.'); | ||
|
||
Route::get('/invalid', function () { | ||
return [ | ||
[ | ||
'id' => 1, | ||
'name' => 'Jim', | ||
'email' => '[email protected]', | ||
], | ||
]; | ||
})->middleware(Middleware::class); | ||
|
||
$this->getJson('/invalid') | ||
->assertValidRequest(); | ||
} | ||
|
||
public function test_fails_asserts_invalid_path_without_exception_handling() | ||
{ | ||
$this->expectException(ErrorException::class); | ||
$this->expectExceptionMessage('Path [GET /invalid] not found in spec.'); | ||
|
||
Route::get('/invalid', function () { | ||
return [ | ||
[ | ||
'id' => 1, | ||
'name' => 'Jim', | ||
'email' => '[email protected]', | ||
], | ||
]; | ||
})->middleware(Middleware::class); | ||
|
||
$this->withoutExceptionHandling(); | ||
|
||
$this->getJson('/invalid') | ||
->assertValidRequest(); | ||
} | ||
|
||
public function test_exception_points_to_mixin_method() | ||
{ | ||
$this->expectException(\ErrorException::class); | ||
|