/symfony-testing
Symfony testing — PHPUnit test organization, unit tests, integration tests, functional tests, TDD workflow, PHPStan, mocking ports, test patterns. Triggers on: test, PHPUnit, TDD, unit test, integration test, functional test, mock, testing, test driven, code quality, PHPStan
$ npx -y skills add aligundogdu/symfony-hexagonal-skill --skill symfony-testing --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.
- You can call itInvoke it directly when you want it.
- Slash command
/symfony-testing
Context preview
The summary Claude sees to decide when to auto-load this skill.
Symfony testing — PHPUnit test organization, unit tests, integration tests, functional tests, TDD workflow, PHPStan, mocking ports, test patterns. Triggers on: test, PHPUnit, TDD, unit test, integration test, functional test, mock, testing, test driven, code quality, PHPStan
SKILL.md
symfony-testing.SKILL.mddescription: "Symfony testing — PHPUnit test organization, unit tests, integration tests, functional tests, TDD workflow, PHPStan, mocking ports, test patterns. Triggers on: test, PHPUnit, TDD, unit test, integration test, functional test, mock, testing, test driven, code quality, PHPStan"
Symfony Testing
You are an expert in testing within Symfony hexagonal architecture.
When to Activate
- User needs to write tests
- User asks about test organization or TDD
- User needs mocking strategies for ports
- User asks about PHPStan or code quality
- User mentions test-driven development
Test Directory Structure (Mirrors src/)
tests/
├── Unit/
│ └── Domain/
│ └── {Module}/
│ ├── Entity/
│ │ └── {Entity}Test.php
│ └── ValueObject/
│ └── {ValueObject}Test.php
├── Integration/
│ └── Application/
│ └── {Module}/
│ ├── Command/
│ │ └── {Handler}Test.php
│ └── Query/
│ └── {Handler}Test.php
├── Functional/
│ └── Presentation/
│ └── {Module}/
│ └── API/
│ └── {Controller}Test.php
└── Support/
└── Adapter/
└── InMemory{Repository}.phpTest Types by Layer
Unit Tests (Domain) — Pure PHP, no framework
namespace Tests\Unit\Domain\User\ValueObject;
use App\Domain\User\ValueObject\Email;
use App\Domain\User\Exception\InvalidEmailException;
use PHPUnit\Framework\TestCase;
final class EmailTest extends TestCase
{
public function test_valid_email_is_created(): void
{
$email = new Email('user@example.com');
$this->assertSame('user@example.com', $email->value);
}
public function test_invalid_email_throws_exception(): void
{
$this->expectException(InvalidEmailException::class);
new Email('invalid');
}
public function test_emails_are_equal(): void
{
$email1 = new Email('user@example.com');
$email2 = new Email('user@example.com');
$this->assertTrue($email1->equals($email2));
}
}Integration Tests (Application) — Mock ports
namespace Tests\Integration\Application\User\Command;
use App\Application\User\Command\RegisterUser;
use App\Application\User\Command\RegisterUserHandler;
use App\Domain\User\Port\UserRepositoryInterface;
use PHPUnit\Framework\TestCase;
final class RegisterUserHandlerTest extends TestCase
{
public function test_it_registers_a_user(): void
{
$repository = $this->createMock(UserRepositoryInterface::class);
$repository->expects($this->once())->method('save');
$repository->method('existsByEmail')->willReturn(false);
$handler = new RegisterUserHandler($repository);
$result = $handler(new RegisterUser('test@example.com', 'Test', 'password123'));
$this->assertNotEmpty($result);
}
}Functional Tests (Presentation) — Full HTTP stack
namespace Tests\Functional\Presentation\User\API;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
final class UserControllerTest extends WebTestCase
{
public function test_create_user(): void
{
$client = static::createClient();
$client->request('POST', '/api/users', [], [], [
'CONTENT_TYPE' => 'application/json',
], json_encode([
'email' => 'test@example.com',
'name' => 'Test User',
'password' => 'Password123',
]));
$this->assertResponseStatusCodeSame(201);
$response = json_decode($client->getResponse()->getContent(), true);
$this->assertNotNull($response['result']['id']);
$this->assertNull($response['error']);
}
}TDD Workflow
1. Write test first (RED) 2. Write minimal code to pass (GREEN) 3. Refactor (REFACTOR) 4. Run PHPStan 5. Repeat
References
See `references/` for detailed guides:
- `test-organization.md` — phpunit.xml config, test suites, fixtures
- `test-patterns.md` — In-memory adapters, test builders, assertion helpers
Read more
description: "Symfony testing — PHPUnit test organization, unit tests, integration tests, functional tests, TDD workflow, PHPStan, mocking ports, test patterns. Triggers on: test, PHPUnit, TDD, unit test, integration test, functional test, mock, testing, test driven, code quality, PHPStan"
Symfony Testing
You are an expert in testing within Symfony hexagonal architecture.
When to Activate
- User needs to write tests
- User asks about test organization or TDD
- User needs mocking strategies for ports
- User asks about PHPStan or code quality
- User mentions test-driven development
Test Directory Structure (Mirrors src/)
tests/
├── Unit/
│ └── Domain/
│ └── {Module}/
│ ├── Entity/
│ │ └── {Entity}Test.php
│ └── ValueObject/
│ └── {ValueObject}Test.php
├── Integration/
│ └── Application/
│ └── {Module}/
│ ├── Command/
│ │ └── {Handler}Test.php
│ └── Query/
│ └── {Handler}Test.php
├── Functional/
│ └── Presentation/
│ └── {Module}/
│ └── API/
│ └── {Controller}Test.php
└── Support/
└── Adapter/
└── InMemory{Repository}.phpTest Types by Layer
Unit Tests (Domain) — Pure PHP, no framework
namespace Tests\Unit\Domain\User\ValueObject;
use App\Domain\User\ValueObject\Email;
use App\Domain\User\Exception\InvalidEmailException;
use PHPUnit\Framework\TestCase;
final class EmailTest extends TestCase
{
public function test_valid_email_is_created(): void
{
$email = new Email('user@example.com');
$this->assertSame('user@example.com', $email->value);
}
public function test_invalid_email_throws_exception(): void
{
$this->expectException(InvalidEmailException::class);
new Email('invalid');
}
public function test_emails_are_equal(): void
{
$email1 = new Email('user@example.com');
$email2 = new Email('user@example.com');
$this->assertTrue($email1->equals($email2));
}
}Integration Tests (Application) — Mock ports
namespace Tests\Integration\Application\User\Command;
use App\Application\User\Command\RegisterUser;
use App\Application\User\Command\RegisterUserHandler;
use App\Domain\User\Port\UserRepositoryInterface;
use PHPUnit\Framework\TestCase;
final class RegisterUserHandlerTest extends TestCase
{
public function test_it_registers_a_user(): void
{
$repository = $this->createMock(UserRepositoryInterface::class);
$repository->expects($this->once())->method('save');
$repository->method('existsByEmail')->willReturn(false);
$handler = new RegisterUserHandler($repository);
$result = $handler(new RegisterUser('test@example.com', 'Test', 'password123'));
$this->assertNotEmpty($result);
}
}Functional Tests (Presentation) — Full HTTP stack
namespace Tests\Functional\Presentation\User\API;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
final class UserControllerTest extends WebTestCase
{
public function test_create_user(): void
{
$client = static::createClient();
$client->request('POST', '/api/users', [], [], [
'CONTENT_TYPE' => 'application/json',
], json_encode([
'email' => 'test@example.com',
'name' => 'Test User',
'password' => 'Password123',
]));
$this->assertResponseStatusCodeSame(201);
$response = json_decode($client->getResponse()->getContent(), true);
$this->assertNotNull($response['result']['id']);
$this->assertNull($response['error']);
}
}TDD Workflow
1. Write test first (RED) 2. Write minimal code to pass (GREEN) 3. Refactor (REFACTOR) 4. Run PHPStan 5. Repeat
References
See `references/` for detailed guides:
- `test-organization.md` — phpunit.xml config, test suites, fixtures
- `test-patterns.md` — In-memory adapters, test builders, assertion helpers
A Claude Code plugin that enforces hexagonal architecture (ports & adapters) in Symfony projects. Works with both new projects (full scaffolding) and existing projects (progressive, module-by-module refactoring).
Other skills on symfony-hexagonal-skill.
- /symfony-api-response
Symfony API response standardization — JSON payload format, exception handling, controllers, REST endpoints, error responses, debug mode. Triggers on: API, endpoint, controller, response, error handling, JSON, REST, API response, exception subscriber, HTTP
Open skill - /symfony-cqrs-handlers
Symfony CQRS command/query handlers — commands, queries, handlers, bus configuration, use cases. Triggers on: command, query, handler, CQRS, bus, use case, command handler, query handler, message bus
Open skill - /symfony-doctrine-persistence
Symfony Doctrine persistence — repository adapters, entity mapping, migrations, transactions, database patterns. Triggers on: doctrine, repository, persistence, database, mapping, migration, ORM, entity manager, DBAL, transaction
Open skill - /symfony-domain-modeling
Symfony domain modeling — entities, value objects, domain events, aggregates, domain exceptions. Triggers on: entity, value object, domain event, aggregate, domain exception, domain model, domain logic, business rule, invariant
Open skill - /symfony-hexagonal-architecture
Symfony hexagonal architecture setup — project structure, module scaffolding, layer responsibilities, dependency rules. Triggers on: architecture, module, layer, hexagonal, scaffold, project structure, directory structure, new project, new module
Open skill - /symfony-messenger-async
Symfony Messenger async processing — message queues, retry strategies, failure transport, Symfony Scheduler, idempotency patterns, background jobs. Triggers on: messenger, async, queue, retry, scheduler, background job, worker, transport, message queue, cron, scheduled task
Open skill

