Skip to content

Commit

Permalink
Refactor CI workflow + dependencies and improve test reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhinegi2 committed Feb 21, 2025
1 parent 27e2b8d commit 416ed88
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 9 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,24 @@ jobs:
# Static analysis using Larastan
- name: Run Larastan
run: ./vendor/bin/phpstan analyse app routes --memory-limit=2G

# Run PHPUnit Tests
- name: Run PHPUnit Tests
env:
DB_CONNECTION: mysql
DB_DATABASE: testing_db
DB_USERNAME: user
DB_PASSWORD: password
DB_HOST: 127.0.0.1
run: |
php artisan config:clear
php artisan cache:clear
php artisan test --testsuite=Feature --stop-on-failure
# Optional: Upload Test Results (JUnit format) for better visibility in CI
- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v3
with:
name: test-results
path: storage/test-results
12 changes: 6 additions & 6 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ public function register(): void
public function boot(): void
{
ResetPassword::createUrlUsing(function (object $notifiable, string $token) {
return config('app.frontend_url')."/password-reset/$token?email={$notifiable->getEmailForPasswordReset()}";
return config('app.frontend_url') . "/password-reset/$token?email={$notifiable->getEmailForPasswordReset()}";
});

Gate::after(function ($user, $ability) {
if($user->hasRole('admin')){
return true;
}
return false;
Gate::after(function ($user) {
if ($user->hasRole('admin')) {
return true;
}
return false;
});
}
}
4 changes: 2 additions & 2 deletions tests/Feature/Auth/AuthenticationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
]);

$this->assertAuthenticated();
$response->assertNoContent();
$response->assertStatus(200);
});

test('users can not authenticate with invalid password', function () {
Expand All @@ -31,5 +31,5 @@
$response = $this->actingAs($user)->post('/logout');

$this->assertGuest();
$response->assertNoContent();
$response->assertStatus(200);
});
2 changes: 1 addition & 1 deletion tests/Feature/Auth/RegistrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
]);

$this->assertAuthenticated();
$response->assertNoContent();
$response->assertStatus(201);
});

0 comments on commit 416ed88

Please sign in to comment.