Laravel testing and verification
Verifies Laravel behavior with focused endpoint, permission and persistence tests using the project's existing test framework.
laravel-testing
See how it helpsWhen is it useful?
Use when a Laravel change needs proof of successful and rejected paths.
What does it help you do?
- Creates independent fixtures and controlled time for repeatable assertions.
- Checks responses and database state for validation and cross-tenant failures.
- Fakes relevant external boundaries and verifies intended and forbidden effects.
Try asking this
Test our invoice endpoint for valid creation, rejected input and foreign-tenant access, confirming no notification on denied requests. Assert the response, stored invoice count and notification fake together. A denied request must create neither an invoice nor a message.
Detailed documentation
Read the skill’s original instructions, examples and checks in their authored language.
Show less
Laravel Testing & Verification
Test runner and isolation
- Match the project's test framework (Pest or PHPUnit) and traits (
RefreshDatabaseorDatabaseTransactions). Run the smallest targeted filter first (php artisan test --compact --filter=...orvendor/bin/pest), and never run destructive database commands against an unverified database. - Each test sets up its own data via model factories with expressive states,
->for(),->has(),->recycle()and->sequence(). Freeze time with$this->travelTo()when testing expiration, schedules or rate limits.
Endpoint, authorization and validation coverage
- Test HTTP endpoints end to end (
actingAs($user)->postJson(...)): assert the specific status (assertCreated(),assertOk(),assertNoContent(),assertForbidden(),assertNotFound(),assertUnprocessable()), response payload (assertJsonPath) and database state (assertDatabaseHas,assertDatabaseMissing,assertSoftDeleted). - Cover the security boundaries: unauthenticated access (
401/ redirect), unauthorized role (403), and cross-tenant or another user's resource (404or403, and assert the foreign record is unchanged in the database). - Cover key
422validation failures withassertInvalid(['field'])(use datasets for validation matrices) and assert no side effects occurred.
Fakes and side effects
- Fake only the external boundary under test (
Queue::fake(),Event::fake([SpecificEvent::class]),Notification::fake(),Mail::fake(),Http::fake(),Storage::fake('s3')) rather than mocking Eloquent models or internal repositories. - Pair positive assertions (
Queue::assertPushed,Mail::assertQueued) with negative assertions (Queue::assertNothingPushed,Mail::assertNothingSent) on failure paths. Never weaken an assertion just to make a failing test pass.
Included files 2
LICENSE.txtSKILL.md
About this skill package
laravel-testing
laravel-testing: Build and maintain Laravel applications with consistent Eloquent models, queues, authorization and tested upgrades.
Show less
laravel-testing
laravel-testing: Build and maintain Laravel applications with consistent Eloquent models, queues, authorization and tested upgrades.
Includes the complete skill and its supporting files (2 files). The exact authored scope is preserved below.
Original skill description (source language)
Use when writing, running or reviewing Pest or PHPUnit feature and unit tests in a Laravel application: RefreshDatabase, model factories, HTTP assertions, policy and tenant isolation tests, validation tests and facade fakes.
Install the skill, review its source and trust settings, then enable it for the relevant project or agent.
Requirements
- Orqestria installed on your computer.
