From 5a4b8f511e47b5fd85c344b2aeea85fbe704eadb Mon Sep 17 00:00:00 2001 From: Mohamed Gaber Date: Sun, 10 Sep 2023 16:54:41 +0300 Subject: [PATCH] add github workflow | use pint --- .github/workflows/tests.yml | 36 ++++++++++++++++++++++++++++++ tests/Feature/AuthTokenTest.php | 2 -- tests/Feature/RefreshTokenTest.php | 2 -- tests/Pest.php | 5 ++--- tests/TestCase.php | 1 - 5 files changed, 38 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..dc1206c --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,36 @@ +name: run-tests + +on: [push, pull_request] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + php: [8.2, 8.1] + dependency-version: [prefer-lowest, prefer-stable] + + name: PHP ${{ matrix.php }} - ${{ matrix.dependency-version }} - ${{ matrix.os }} + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none + + - name: Install dependencies + run: | + composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction + + - name: Code Style 🏭 + run: composer test:lint + + - name: Pest Tests + run: composer test:unit + + - name: PHPStan + run: composer test:static diff --git a/tests/Feature/AuthTokenTest.php b/tests/Feature/AuthTokenTest.php index 4ecef3d..b4201dd 100644 --- a/tests/Feature/AuthTokenTest.php +++ b/tests/Feature/AuthTokenTest.php @@ -2,8 +2,6 @@ declare(strict_types=1); -use Tests\Datasets\User; - it('auth token can be generated with expires time from config', function () { $this->freezeTime(); $authToken = $this->user->createAuthToken('auth'); diff --git a/tests/Feature/RefreshTokenTest.php b/tests/Feature/RefreshTokenTest.php index c5bff2b..c7d0ff6 100644 --- a/tests/Feature/RefreshTokenTest.php +++ b/tests/Feature/RefreshTokenTest.php @@ -2,8 +2,6 @@ declare(strict_types=1); -use Tests\Datasets\User; - it('refresh token can be generated with expires time from config', function () { $this->freezeTime(); $refreshToken = $this->user->createRefreshToken('refresh'); diff --git a/tests/Pest.php b/tests/Pest.php index 52e1e35..8ce195e 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -19,15 +19,14 @@ uses( Tests\TestCase::class, RefreshDatabase::class -)->beforeEach(function (){ +)->beforeEach(function () { Route::post('api/refresh-token', fn () => response(['message' => 'success']))->name('api.token.refresh')->middleware('auth:sanctum'); Route::post('api/other-route', fn () => response(['message' => 'success']))->name('api.other-route')->middleware('auth:sanctum'); Route::post('api/refresh-token1', fn () => response(['message' => 'success']))->name('api.token.refresh1')->middleware('auth:sanctum'); Route::post('api/refresh-token2', fn () => response(['message' => 'success']))->name('api.token.refresh2')->middleware('auth:sanctum'); - $this->user = User::factory()->create(); + $this->user = User::factory()->create(); })->in('Feature'); - /* |-------------------------------------------------------------------------- | Expectations diff --git a/tests/TestCase.php b/tests/TestCase.php index e363337..a98a9bb 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -5,7 +5,6 @@ namespace Tests; use Illuminate\Database\Schema\Blueprint; -use Illuminate\Routing\Router; use Illuminate\Support\Facades\Schema; use Laravel\Sanctum\SanctumServiceProvider; use MohamedGaber\SanctumRefreshToken\SanctumRefreshTokenServiceProvider;