diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 9b73d24..24f7332 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -12,6 +12,10 @@ jobs: strategy: matrix: include: + - php: 8.5 + env: + laravel: 12.* + testbench: 10.* - php: 8.4 env: laravel: 10.* @@ -51,6 +55,9 @@ jobs: composer require "laravel/framework:${laravel}" "orchestra/testbench:${testbench}" --no-interaction --no-update --prefer-dist composer update --prefer-stable --prefer-dist --no-interaction + - name: Run Security Audit + run: composer audit + - name: List Installed Dependencies run: composer show -D diff --git a/tests/Feature/AuthenticationTest.php b/tests/Feature/AuthenticationTest.php index ac254d2..e6dfe83 100755 --- a/tests/Feature/AuthenticationTest.php +++ b/tests/Feature/AuthenticationTest.php @@ -3,6 +3,7 @@ namespace Code16\Machina\Tests\Feature; use Code16\Machina\Tests\MachinaTestCase; +use PHPUnit\Framework\Attributes\Test; class AuthenticationTest extends MachinaTestCase { @@ -15,7 +16,7 @@ public function setUp(): void })->middleware('auth:machina'); } - /** @test */ + #[Test] function client_can_access_a_protected_route_with_a_valid_token_in_header() { $client = $this->createClient("1234"); @@ -34,7 +35,7 @@ function client_can_access_a_protected_route_with_a_valid_token_in_header() $response->assertStatus(200); } - /** @test */ + #[Test] function client_can_access_a_protected_route_with_a_valid_token_in_url() { $client = $this->createClient("1234"); @@ -50,14 +51,14 @@ function client_can_access_a_protected_route_with_a_valid_token_in_url() $response->assertStatus(200); } - /** @test */ + #[Test] function accessing_a_protected_route_without_a_token_returns_400() { $response = $this->json('get', '/protected'); $response->assertStatus(400); } - /** @test */ + #[Test] function accessing_a_protected_route_with_an_invalid_token_returns_401() { $headers = [ @@ -67,7 +68,7 @@ function accessing_a_protected_route_with_an_invalid_token_returns_401() $response->assertStatus(400); } - /** @test */ + #[Test] function user_is_authenticated_when_a_protected_route_is_accessed() { $client = $this->createClient("1234"); @@ -88,7 +89,7 @@ function user_is_authenticated_when_a_protected_route_is_accessed() $this->assertEquals($client->id, auth()->user()->id); } - /** @test */ + #[Test] function token_is_not_returned_inside_response_headers_when_not_refreshed_by_middleware() { $client = $this->createClient("1234"); @@ -108,7 +109,7 @@ function token_is_not_returned_inside_response_headers_when_not_refreshed_by_mid $this->assertFalse(array_key_exists("authorization", $response->headers->all())); } - /** @test */ + #[Test] function user_is_set_after_a_successful_authentication() { $this->app->make('router')->get('user', function() { diff --git a/tests/Feature/GenerateKeyTest.php b/tests/Feature/GenerateKeyTest.php index 5c1082d..9f1c189 100755 --- a/tests/Feature/GenerateKeyTest.php +++ b/tests/Feature/GenerateKeyTest.php @@ -4,11 +4,12 @@ use Artisan; use Code16\Machina\Tests\MachinaTestCase; +use PHPUnit\Framework\Attributes\Test; class GenerateKeyTest extends MachinaTestCase { - /** @test */ + #[Test] function we_can_call_the_artisan_command_to_generate_keys() { Artisan::call('machina:keys'); diff --git a/tests/Feature/LoginTest.php b/tests/Feature/LoginTest.php index eab8218..62512d3 100755 --- a/tests/Feature/LoginTest.php +++ b/tests/Feature/LoginTest.php @@ -3,10 +3,11 @@ namespace Code16\Machina\Tests\Feature; use Code16\Machina\Tests\MachinaTestCase; +use PHPUnit\Framework\Attributes\Test; class LoginTest extends MachinaTestCase { - /** @test */ + #[Test] function login_with_valid_credentials_returns_a_jwt_token() { $client = $this->createClient("1234"); @@ -18,7 +19,7 @@ function login_with_valid_credentials_returns_a_jwt_token() $response->assertStatus(200); } - /** @test */ + #[Test] function login_with_invalid_credentials_returns_a_401() { $client = $this->createClient("1234"); @@ -28,9 +29,9 @@ function login_with_invalid_credentials_returns_a_401() ]; $response = $this->json('post', '/auth/login', $data); $response->assertStatus(401); - } + } - /** @test */ + #[Test] function login_with_no_credentials_parameters_returns_a_401() { $client = $this->createClient("1234"); diff --git a/tests/Feature/RefreshTest.php b/tests/Feature/RefreshTest.php index a41ea49..8669589 100755 --- a/tests/Feature/RefreshTest.php +++ b/tests/Feature/RefreshTest.php @@ -4,11 +4,12 @@ use Code16\Machina\Middleware\RefreshToken; use Code16\Machina\Tests\MachinaTestCase; +use PHPUnit\Framework\Attributes\Test; class RefreshTest extends MachinaTestCase { - /** @test */ + #[Test] function we_can_refresh_the_token_using_middleware() { $this->app