php-template/tests/Pest.php
Snider 4833d922c5 feat(testing): add Pest configuration, example tests, and composer scripts
- Add tests/Pest.php with TestCase binding and RefreshDatabase
- Add example feature tests: WelcomePageTest, HealthEndpointTest
- Add composer scripts: lint, test, test:coverage

Implements P2-049, P2-050, P2-051

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 13:37:20 +00:00

72 lines
2.1 KiB
PHP

<?php
declare(strict_types=1);
/*
|--------------------------------------------------------------------------
| Pest Configuration
|--------------------------------------------------------------------------
|
| Configure Pest testing framework for the Core PHP Framework template.
| This file binds test traits to test cases and provides helper functions.
|
*/
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
/*
|--------------------------------------------------------------------------
| Test Case
|--------------------------------------------------------------------------
|
| The closure passed to the "uses()" method binds an abstract test case
| to all Feature and Unit tests. The TestCase class provides a bridge
| between Laravel's testing utilities and Pest's expressive syntax.
|
*/
uses(TestCase::class)->in('Feature', 'Unit');
/*
|--------------------------------------------------------------------------
| Database Refresh
|--------------------------------------------------------------------------
|
| Apply RefreshDatabase to Feature tests that need a clean database state.
| Unit tests typically don't require database access.
|
*/
uses(RefreshDatabase::class)->in('Feature');
/*
|--------------------------------------------------------------------------
| Expectations
|--------------------------------------------------------------------------
|
| You may extend Pest's expectations with custom methods here. These
| custom expectations can be used in any test throughout your application.
|
| For example:
| expect()->extend('toBeUkEnglish', function () {
| return $this->not->toContain('color')
| ->not->toContain('organization');
| });
|
*/
/*
|--------------------------------------------------------------------------
| Functions
|--------------------------------------------------------------------------
|
| You may define custom helper functions for your tests here. These
| functions will be available in all your test files.
|
| For example:
| function createWorkspace(array $attributes = []): Workspace {
| return Workspace::factory()->create($attributes);
| }
|
*/