Symfony testing
Skill aligundogdu/symfony-hexagonal-skill/skills/symfony-testing
Claude Code plugin that enforces hexagonal architecture (ports & adapters) in Symfony projects — with 10 auto-triggered skills, 2 review agents, and progressive refactoring support for existing codebases.
npx -y skills add aligundogdu/symfony-hexagonal-skill --skill symfony-testingAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
What its author says it does
Copied from the file, not written here
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
4.1 KB, as published. Nobody here has run it
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}.php
Test 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('[email protected]');
$this->assertSame('[email protected]', $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('[email protected]');
$email2 = new Email('[email protected]');
$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('[email protected]', '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' => '[email protected]',
'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
- Write test first (RED)
- Write minimal code to pass (GREEN)
- Refactor (REFACTOR)
- Run PHPStan
- Repeat
References
See references/ for detailed guides:
test-organization.md— phpunit.xml config, test suites, fixturestest-patterns.md— In-memory adapters, test builders, assertion helpers