diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index c1fc195..2918789 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -1,4 +1,4 @@ -name: run-tests +name: Pest on: push: @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: true matrix: - os: [ubuntu-latest, windows-latest] + os: [ubuntu-latest] php: [8.3, 8.2] laravel: [11.*, 10.*] stability: [prefer-lowest, prefer-stable] diff --git a/composer.json b/composer.json index 75a276e..39fb8bf 100644 --- a/composer.json +++ b/composer.json @@ -49,6 +49,7 @@ "autoload-dev": { "psr-4": { "Raiolanetworks\\OAuth\\Tests\\": "tests/", + "Raiolanetworks\\OAuth\\Tests\\Database\\Factories\\": "tests/database/factories/", "Workbench\\App\\": "workbench/app/", "Workbench\\Database\\Factories\\": "workbench/database/factories/", "Workbench\\Database\\Seeders\\": "workbench/database/seeders/" diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 91f428b..2bb5b07 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -15,11 +15,8 @@ backupStaticProperties="false" > - - ./tests/Unit - - - ./tests/Feature + + tests diff --git a/src/Commands/OAuthCommand.php b/src/Commands/OAuthCommand.php index b9c0b87..6c37fdf 100644 --- a/src/Commands/OAuthCommand.php +++ b/src/Commands/OAuthCommand.php @@ -59,9 +59,9 @@ protected function setConfigVariables(): void ); $loginRoute = text( - label: 'Login route:', - placeholder: 'E.g. /login', - default: '/login', + label: 'Login route name:', + placeholder: 'E.g. login', + default: 'login', ); config()->set('oauth.user_model_name', $modelName); diff --git a/tests/Feature/CommandTest.php b/tests/Feature/CommandTest.php index aa28806..35b1bb0 100644 --- a/tests/Feature/CommandTest.php +++ b/tests/Feature/CommandTest.php @@ -12,7 +12,7 @@ $this->artisan('oauth:install') ->expectsQuestion('Model name Authenticatable:', TestUser::class) ->expectsQuestion('Main guard name:', 'web') - ->expectsQuestion('Login route:', '/login') + ->expectsQuestion('Login route name:', 'login') ->expectsQuestion('Oauth base url:', 'https://asgard.your.company') ->expectsQuestion('Oauth client ID:', 'CLIENTID') ->expectsQuestion('Oauth client secret key:', 'SECRETKEY') diff --git a/tests/Feature/ControllerTest.php b/tests/Feature/ControllerTest.php index ce0f82b..f392a93 100644 --- a/tests/Feature/ControllerTest.php +++ b/tests/Feature/ControllerTest.php @@ -71,7 +71,7 @@ // Temporal route Route::get('/login', function () { return 'Login Page'; - })->name(config()->string('oauth.login_route_name')); + })->name(config('oauth.login_route_name')); Session::put('oauth2-state', 'correct_state'); @@ -79,7 +79,7 @@ 'state' => 'correct_state', ]); - $response->assertRedirect(route(config()->string('oauth.login_route_name'))) + $response->assertRedirect(route(config('oauth.login_route_name'))) ->assertSessionHas('message', 'Authentication failed. Please try again.'); }); @@ -87,13 +87,13 @@ // Temporal route Route::get('/login', function () { return 'Login Page'; - })->name(config()->string('oauth.login_route_name')); + })->name(config('oauth.login_route_name')); $response = $this->get(route('oauth.callback', [ 'code' => 'valid_code', ])); - $response->assertRedirect(route(config()->string('oauth.login_route_name'))) + $response->assertRedirect(route(config('oauth.login_route_name'))) ->assertSessionHas('message', 'Authentication failed. Please try again.'); }); @@ -101,7 +101,7 @@ // Temporal route Route::get('/login', function () { return 'Login Page'; - })->name(config()->string('oauth.login_route_name')); + })->name(config('oauth.login_route_name')); $mockOAuthService = Mockery::mock(OAuthService::class); @@ -196,7 +196,7 @@ // Temporal route Route::get('/login', function () { return 'Login Page'; - })->name(config()->string('oauth.login_route_name')); + })->name(config('oauth.login_route_name')); $mockOAuthService = Mockery::mock(OAuthService::class); @@ -230,6 +230,6 @@ expect($mockUser->oauth_token_expires_at)->toBeNull(); expect($response->getStatusCode())->toBe(302); - expect($response->headers->get('Location'))->toBe(route(config()->string('oauth.login_route_name'))); + expect($response->headers->get('Location'))->toBe(route(config('oauth.login_route_name'))); expect(session('message'))->toBe('Your session has expired. Please log in again.'); });