원클릭으로
phpunit
PHPUnit test structure, naming, assertions, and factory conventions for Laravel feature and unit tests.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
PHPUnit test structure, naming, assertions, and factory conventions for Laravel feature and unit tests.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Readonly data containers with typed factory methods (`fromArray`, `fromModel`, `fromCollection`, `fromRequest`) used to pass structured data between application layers — especially for external API responses, Eloquent models, and service boundaries. Use this skill whenever creating, reviewing, or refactoring DTOs, Data Transfer Objects, value objects for inter-layer communication, or mapping payloads from APIs, models, or collections into typed PHP objects. Also trigger when the user mentions spatie/laravel-data alternatives, data mapping, or payload normalization in a Laravel context.
Eloquent model conventions for mass assignment, casts, relationship naming, activity logging, and mandatory model tests (CRUD + relations).
Single-purpose business logic classes that encapsulate one well-defined business operation. Actions are the primary location for business logic in Laravel applications, invoked from controllers, commands, or jobs.
Albatros accounting API integration via Saloon. Use when working with app/Services/Albatros/, AlbatrosConnector, or Albatros DTOs.
Laravel Blade template conventions covering components, output escaping, security, structure, and formatting.
Artisan console command classes that serve as the CLI entry point for operations. Commands validate input and delegate all business logic to Actions or Services.
| name | phpunit |
| description | PHPUnit test structure, naming, assertions, and factory conventions for Laravel feature and unit tests. |
| compatible_agents | ["test","refactor","review"] |
phpunit.xml / phpunit.xml.dist is present and configured for this project.tests/Unit) vs feature (tests/Feature).RefreshDatabase in feature tests that modify/query DB state.assertSame) when type and value matter.Tests\TestCase; unit tests extend PHPUnit\Framework\TestCase.test_ snake_case method names and : void return types.// Feature test
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class InvoiceControllerTest extends TestCase
{
use RefreshDatabase;
public function test_user_can_create_invoice(): void
{
$user = User::factory()->create();
$order = Order::factory()->create(['user_id' => $user->id]);
$response = $this->actingAs($user)
->postJson('/api/invoices', ['order_id' => $order->id]);
$response->assertStatus(201);
$this->assertDatabaseHas('invoices', ['order_id' => $order->id]);
}
}
// Unit test — no Laravel bootstrap
use PHPUnit\Framework\TestCase;
class MoneyHelperTest extends TestCase
{
public function test_formats_amount_in_cents_as_currency_string(): void
{
$result = MoneyHelper::format(1000, 'CHF');
$this->assertSame('10.00 CHF', $result);
}
}
// Factory with states
// database/factories/UserFactory.php
public function unverified(): static
{
return $this->state(fn (array $attributes) => [
'email_verified_at' => null,
]);
}
// Usage in tests
User::factory()->create();
User::factory()->unverified()->create();
# Full Laravel test run (recommended entrypoint)
php artisan test
# Run PHPUnit directly
vendor/bin/phpunit
# Run a single file
vendor/bin/phpunit tests/Feature/InvoiceControllerTest.php
# Filter by test method name
vendor/bin/phpunit --filter=test_user_can_create_invoice
RefreshDatabase in feature tests that write to the databaseinsert() or create() calls in tests instead of factoriesassertEquals when assertSame is needed for strict comparisonassertTrue($result !== null)) instead of a specific valueTests\TestCase only for feature tests)PestTesting/SKILL.md — the preferred test framework (Pest over raw PHPUnit)