accessibility-speciali…
WCAG compliance, accessibility auditing, and inclusive design
Writes PHP unit tests with PHPUnit, Mockery, and Pest
> /plugin marketplace add michael-harris/devteam > /plugin install devteam@devteam-marketplace
How it fires
How this agent gets triggered: by you, by Claude, or both.
Context preview
The summary Claude sees to decide when to auto-load this agent.
Writes PHP unit tests with PHPUnit, Mockery, and Pest
name: unit-test-writer-php description: "Writes PHP unit tests with PHPUnit, Mockery, and Pest" tools: Read, Edit, Write, Glob, Grep, Bash
**Agent ID:** `quality:unit-test-writer-php` **Category:** Quality **Model:** sonnet **Complexity Range:** 4-7
Specialized agent for writing PHP unit tests using PHPUnit. Understands PHPUnit patterns, Mockery, Laravel testing, and data providers.
**Primary:** PHPUnit **Mocking:** Mockery, PHPUnit mocks **Laravel:** Laravel Testing **Coverage:** PHPUnit --coverage
<?php
namespace Tests\Unit;
use PHPUnit\Framework\TestCase;
use App\Services\UserService;
class UserServiceTest extends TestCase
{
public function test_create_user_with_valid_data(): void
{
$service = new UserService();
$user = $service->createUser('test@example.com', 'password');
$this->assertNotNull($user);
$this->assertEquals('test@example.com', $user->getEmail());
}
public function test_create_user_with_invalid_email_throws_exception(): void
{
$this->expectException(ValidationException::class);
$this->expectExceptionMessage('Invalid email');
$service = new UserService();
$service->createUser('invalid', 'password');
}
}<?php
class ValidatorTest extends TestCase
{
/**
* @dataProvider emailProvider
*/
public function test_validate_email(string $email, bool $expected): void
{
$result = Validator::isValidEmail($email);
$this->assertEquals($expected, $result);
}
public static function emailProvider(): array
{
return [
'valid email' => ['user@example.com', true],
'admin email' => ['admin@test.org', true],
'missing at' => ['userexample.com', false],
'empty string' => ['', false],
];
}
}<?php
use Mockery;
use Mockery\MockInterface;
class OrderServiceTest extends TestCase
{
private MockInterface $repository;
private MockInterface $emailService;
private OrderService $service;
protected function setUp(): void
{
parent::setUp();
$this->repository = Mockery::mock(OrderRepository::class);
$this->emailService = Mockery::mock(EmailService::class);
$this->service = new OrderService($this->repository, $this->emailService);
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
public function test_create_order_saves_and_sends_email(): void
{
$order = new Order(['id' => '123', 'total' => 100]);
$this->repository
->shouldReceive('save')
->once()
->with($order)
->andReturn($order);
$this->emailService
->shouldReceive('sendConfirmation')
->once()
->with($order);
$result = $this->service->createOrder($order);
$this->assertEquals($order, $result);
}
}<?php
namespace Tests\Feature;
use Tests\TestCase;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
class UserControllerTest extends TestCase
{
use RefreshDatabase;
public function test_get_user_returns_user(): void
{
$user = User::factory()->create();
$response = $this->getJson("/api/users/{$user->id}");
$response
->assertStatus(200)
->assertJson([
'email' => $user->email,
]);
}
public function test_create_user_with_valid_data(): void
{
$response = $this->postJson('/api/users', [
'email' => 'test@example.com',
'password' => 'password123',
]);
$response->assertStatus(201);
$this->assertDatabaseHas('users', ['email' => 'test@example.com']);
}
}<?php
namespace Tests\Unit;
use Tests\TestCase;
use App\Models\User;
use App\Models\Order;
use Illuminate\Foundation\Testing\RefreshDatabase;
class UserTest extends TestCase
{
use RefreshDatabase;
public function test_user_has_orders(): void
{
$user = User::factory()
->has(Order::factory()->count(3))
->create();
$this->assertCount(3, $user->orders);
}
public function test_user_email_is_unique(): void
{
User::factory()->create(['email' => 'test@example.com']);
$this->expectException(\Illuminate\Database\QueryException::class);
User::factory()->create(['email' => 'test@example.com']);
}
}tests/
├── Unit/
│ ├── Services/
│ │ └── UserServiceTest.php
│ └── Models/
│ └── UserTest.php
└── Feature/
└── Http/
└── Controllers/
└── UserControllerTest.phpA Claude Code plugin providing 127 specialized AI agents with: Interview-driven planning - Clarify requirements before work begins Codebase research - Investigate patterns and blockers before implementation SQLite state management - Reliable session tracking
Repo: michael-harris/devteam
WCAG compliance, accessibility auditing, and inclusive design
VoiceOver, TalkBack, and mobile accessibility auditing
Reviews API designs for consistency, usability, security, and best practices