Skip to content

Commit c64f9b8

Browse files
committed
Update tests
1 parent 1c2fbd3 commit c64f9b8

File tree

5 files changed

+57
-4
lines changed

5 files changed

+57
-4
lines changed

tests/Controllers/LaravelRequestDocsControllerTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ public function testApi()
2525
true,
2626
);
2727

28+
$docs = collect($response->json());
29+
30+
/** {@see \Rakutentech\LaravelRequestDocs\Tests\TestCase::registerRoutes()} */
31+
$this->assertCount(28, $docs);
32+
2833
$this->assertSame($expected, $response->json());
2934
}
3035

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace Rakutentech\LaravelRequestDocs\Tests\Stubs\TestControllers;
4+
5+
use Illuminate\Http\Response;
6+
use Rakutentech\LaravelRequestDocs\Tests\Stubs\TestRequests\RequestWithEmptyRules;
7+
8+
class MatchController
9+
{
10+
/**
11+
* Display a listing of the resource.
12+
*/
13+
public function index(RequestWithEmptyRules $request): Response
14+
{
15+
return response('content');
16+
}
17+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace Rakutentech\LaravelRequestDocs\Tests\Stubs\TestRequests;
4+
5+
use Illuminate\Foundation\Http\FormRequest;
6+
7+
class RequestWithEmptyRules extends FormRequest
8+
{
9+
/**
10+
* Determine if the user is authorized to make this request.
11+
*
12+
* @return bool
13+
*/
14+
public function authorize()
15+
{
16+
return true;
17+
}
18+
19+
protected function prepareForValidation()
20+
{
21+
}
22+
23+
/**
24+
* Get the validation rules that apply to the request.
25+
*
26+
* @return array
27+
*/
28+
public function rules()
29+
{
30+
return [];
31+
}
32+
}

tests/TestCase.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,15 @@ public function registerRoutes()
5656

5757
Route::apiResource('accounts', TestControllers\AccountController::class);
5858

59-
Route::any('any', [TestControllers\WelcomeController::class, 'index']);
60-
Route::match(['get', 'post'], 'match', [TestControllers\WelcomeController::class, 'index']);
59+
Route::match(['get', 'post'], 'match', [TestControllers\MatchController::class, 'index']);
6160

6261
// Test duplication
6362
Route::apiResource('accounts', TestControllers\AccountController::class);
6463

6564
// Expected to be skipped
6665
Route::get('telescope', [TestControllers\TelescopeController::class, 'index']);
6766

68-
Route::options('not_included', function () {
67+
Route::options('options_is_not_included', function () {
6968
return false;
7069
});
7170
}

tests/mocks/lrd-response.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)