forked from rakutentech/laravel-request-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestCase.php
73 lines (58 loc) · 2.63 KB
/
TestCase.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
namespace Rakutentech\LaravelRequestDocs\Tests;
use Illuminate\Support\Facades\Route;
use Orchestra\Testbench\TestCase as Orchestra;
use Rakutentech\LaravelRequestDocs\LaravelRequestDocsServiceProvider;
use Rakutentech\LaravelRequestDocs\Tests\Stubs\TestControllers;
class TestCase extends Orchestra
{
public function setUp(): void
{
parent::setUp();
$this->registerRoutes();
}
public function registerRoutes(): void
{
Route::get('/', [TestControllers\WelcomeController::class, 'index']);
Route::get('welcome', [TestControllers\WelcomeController::class, 'index']);
Route::get('welcome/{id}', [TestControllers\WelcomeController::class, 'show']);
Route::post('welcome', [TestControllers\WelcomeController::class, 'store'])->middleware('auth:api');
Route::put('welcome', 'Rakutentech\LaravelRequestDocs\Tests\Stubs\TestControllers\WelcomeController@edit');
Route::patch('welcome/patch', 'Rakutentech\LaravelRequestDocs\Tests\Stubs\TestControllers\WelcomeController@edit');
Route::delete('welcome', [TestControllers\WelcomeController::class, 'destroy']);
Route::get('health', [TestControllers\WelcomeController::class, 'health']);
Route::get('single', TestControllers\SingleActionController::class);
Route::delete('welcome/no-rules', [TestControllers\WelcomeController::class, 'noRules']);
Route::post('comments-on-request-rules-method', [TestControllers\CommentsOnRequestRulesMethodController::class, 'index']);
Route::get('closure', static fn () => true);
Route::apiResource('accounts', TestControllers\AccountController::class);
Route::match(['get', 'post'], 'match', [TestControllers\MatchController::class, 'index']);
// Test duplication
Route::apiResource('accounts', TestControllers\AccountController::class);
// Expected to be skipped
Route::get('telescope', [TestControllers\TelescopeController::class, 'index']);
Route::options('options_is_not_included', static fn () => false);
}
/**
* @inheritDoc
*/
protected function getEnvironmentSetUp($app)
{
app()->setBasePath(__DIR__ . '/../');
$app['config']->set('database.default', 'testing');
$app['config']->set('app.debug', true);
}
/**
* @inheritDoc
*/
protected function getPackageProviders($app)
{
return [
LaravelRequestDocsServiceProvider::class,
];
}
protected function countRoutesWithLRDDoc(): int
{
return count(Route::getRoutes()->getRoutes()) - 2; // Exclude `telescope`, `request-docs`
}
}