Learn Laravel TDD and automated testing with modern practical techniques.
Copy the install command and let the AI configure it · recommended for beginners
Please install the "laravel-tdd" skill from askskill: 1. Download https://raw.githubusercontent.com/affaan-m/ECC/main/skills/laravel-tdd/SKILL.md 2. Save it as ~/.claude/skills/laravel-tdd/SKILL.md 3. Reload skills and tell me it's ready
Using Pest, write Laravel tests for a user registration endpoint covering successful signup, duplicate email, and invalid password cases, and show the related factory setup and assertions.
A runnable set of Pest HTTP tests with factory setup, request examples, and key assertions.
Show how to test Sanctum-protected APIs in Laravel, including authenticated access success, unauthenticated 401 responses, and how to simulate login in tests.
Example Sanctum authentication tests showing how to create auth context and assert API behavior.
I have a Laravel service class that depends on an external payment gateway. Using PHPUnit, explain how to write unit tests with mocking, including cases for success, exceptions, and retry logic.
A PHPUnit unit testing approach with sample code showing mocks, dependency isolation, and coverage strategy.
Test-driven development for Laravel applications using PHPUnit, Pest, Laravel factories, and testing helpers.
// Step 1: RED — Write a failing test
public function test_a_product_can_be_created(): void
{
$product = Product::factory()->create(['name' => 'Test Product']);
$this->assertDatabaseHas('products', ['name' => 'Test Product']);
}
// Step 2: GREEN — Write the migration, model, and factory
// Step 3: REFACTOR — Improve while keeping tests green
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true">
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">tests/Unit</directory>
</testsuite>
<testsuite name="Feature">
<directory suffix="Test.php">tests/Feature</directory>
</testsuite>
</testsuites>
<php>
<env name="APP_ENV" value="testing"/>
<env name="BCRYPT_ROUNDS" value="4"/>
<env name="CACHE_STORE" value="array"/>
<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>
<env name="MAIL_MAILER" value="array"/>
<env name="QUEUE_CONNECTION" value="sync"/>
<env name="SESSION_DRIVER" value="array"/>
</php>
</phpunit>
namespace Tests;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase
{
protected function setUp(): void
{
parent::setUp();
// Call $this->withoutExceptionHandling() only in tests that
// test non-HTTP exceptions; it suppresses assertStatus() etc.
}
// Helper: Authenticate and return user
protected function actingAsUser(): mixed
{
$user = \App\Models\User::factory()->create();
$this->actingAs($user);
return $user;
}
protected function actingAsAdmin(): mixed
{
$admin = \App\Models\User::factory()->admin()->create();
$this->actingAs($admin);
return $admin;
}
}
// database/factories/UserFactory.php
class UserFactory extends Factory
{
protected static ?string $password = null;
public function definition(): array
{
return [
'name' => fake()->name(),
'email' => fake()->unique()->safeEmail(),
'email_verified_at' => now(),
'password' => static::$password ??= Hash::make('password'),
'remember_token' => Str::random(10),
'role' => 'user',
];
}
public function admin(): static
{
return $this->state(fn (array $attributes) => ['role' => 'admin']);
}
public function unverified(): static
{
return $this->state(fn (array $attributes) => ['email_verified_at' => null]);
}
}
// database/factories/ProductFactory.php
class ProductFactory extends Factory
{
public function definition(): array
{
return [
'name' => fake()->unique()->words(3, true),
'slug' => fn (array $attrs) => Str::slug($attrs['name']),
'description' => fake()->paragraph(),
'price' => fake()->numberBetween(100, 100000),
'stock' => fake()->numberBetween(0, 100),
'is_active' => true,
…
Automatically format, lint, and fix code issues on every edit.
Learn robust error-handling patterns across TypeScript, Python, and Go applications.
Audit Claude skills and commands with quick scans or full stocktakes.
Plan demand forecasts, safety stock, and replenishment for multi-location retail inventory.
Create iOS liquid glass interfaces with dynamic visuals and interactive morphing.
Record polished web app UI demo videos for walkthroughs, tutorials, and showcases.
Learn Laravel production architecture patterns and core backend implementation practices.
Build robust Django tests with pytest-django, TDD, mocks, factories, and API coverage.
Build robust Python test suites with pytest, TDD, mocking, and coverage.
Learn Rust testing patterns and TDD to improve code quality and reliability.
Apply Laravel security best practices for auth, vulnerabilities, APIs, and deployment.
Practice test-driven development for Spring Boot features, fixes, and refactoring.