skillfed

phpunit-skill

phpunit-skill streamlines the creation of PHPUnit test suites by automating test case generation, assertion setup, and lifecycle method configuration. Designed for developers building robust PHP testing workflows, this skill reduces boilerplate code and accelerates test-driven development cycles.

phpunit-skill helps you write PHPUnit tests by automating test case generation, assertion setup, and lifecycle method configuration. To write tests, you define a test class extending TestCase, create test methods prefixed with 'test', and use PHPUnit assertions like assertEquals, assertTrue, and assertThrows. phpunit-skill streamlines this process by reducing boilerplate code and accelerating your test-driven development cycles, allowing you to focus on test logic rather than repetitive setup.

AI-generated summary based on this skill's SKILL.md

339 68 MIT updated by LambdaTest

Install

LambdaTest/agent-skills/phpunit-skill · repository language: Python

CLI (skillfed)coming soon
git clone https://github.com/LambdaTest/agent-skills
cp -r agent-skills/phpunit-skill ~/.claude/skills/phpunit-skill

Frequently asked questions

AI-generated answers based on this skill's SKILL.md and metadata

How do I write PHPUnit tests for my PHP code?

phpunit-skill helps you write PHPUnit tests by automating test case generation, assertion setup, and lifecycle method configuration. To write tests, you define a test class extending TestCase, create test methods prefixed with 'test', and use PHPUnit assertions like assertEquals, assertTrue, and assertThrows. phpunit-skill streamlines this process by reducing boilerplate code and accelerating your test-driven development cycles, allowing you to focus on test logic rather than repetitive setup.

What is a PHPUnit assertEquals example and how does phpunit-skill help?

phpunit-skill assists with PHPUnit assertEquals examples by automating assertion setup within your test cases. The assertEquals method compares two values for equality—for instance, assertEquals(5, 2 + 3) verifies that an addition operation produces the expected result. phpunit-skill streamlines assertion configuration so you can quickly structure multiple assertions across your test suite without manual repetition, helping you build comprehensive test coverage faster.

How do I create mock objects and test doubles for dependency isolation in phpunit-skill?

phpunit-skill supports creating mock objects and test doubles through PHPUnit's mocking framework to isolate dependencies during testing. You can use createMock() or getMockBuilder() to generate mock instances of collaborating classes, then configure expectations and return values. phpunit-skill automates the setup of these mocks within your test structure, enabling you to verify that your code interacts correctly with dependencies without executing their actual implementations, which is essential for unit test isolation.

What are PHPUnit data providers and how does phpunit-skill use them?

phpunit-skill leverages PHPUnit data providers to set up data-driven tests that run the same test logic against multiple input datasets. A data provider is a method annotated with @dataProvider that returns arrays of test parameters. Rather than writing duplicate test methods, you define one test method and attach a data provider to execute it repeatedly with different inputs. phpunit-skill automates data provider configuration, allowing you to test edge cases and multiple scenarios efficiently without code duplication.

How does phpunit-skill handle PHPUnit project setup, CI/CD integration, and coverage reporting?

phpunit-skill configures PHPUnit project setup through phpunit.xml, which defines test directories, bootstrap files, and environment settings. For CI/CD integration, phpunit-skill helps you generate coverage reports in formats like Clover or HTML that integrate with continuous integration pipelines. You can configure coverage thresholds, specify which code paths to analyze, and automate test execution within your deployment workflow. phpunit-skill reduces configuration overhead so your testing infrastructure scales alongside your project.

How can phpunit-skill help me test exception handling and edge cases?

phpunit-skill assists with testing exception handling by automating the setup of test methods that verify your code throws expected exceptions under specific conditions. You use assertions like expectException() and expectExceptionMessage() to validate exception behavior. phpunit-skill structures these edge-case tests within your test suite, ensuring you cover error paths and boundary conditions. This capability helps you build resilient PHP code by confirming that exception handling logic works as designed across various failure scenarios.

SKILL.md

rendered from the published skill — quoted content, verbatim

PHPUnit Testing Skill

Core Patterns

Basic Test

```php <?php use PHPUnit\Framework\TestCase;

class CalculatorTest extends TestCase { private Calculator $calculator;

protected function setUp(): void
{
    $this-&gt;calculator = new Calculator();
}

public function testAddition(): void
{
    $this-&gt;assertEquals(5, $this-&gt;calculator-&gt;add(2, 3));
}

public function testDivideByZero(): void
{
    $this-&gt;expectException(\DivisionByZeroError::class);
    $this-&gt;calculator-&gt;divide(10, 0);
}

public function testMultipleAssertions(): void
{
    $this-&gt;assertSame(4, $this-&gt;calculator-&gt;add(2, 2));
    $this-&gt;assertSame(0, $this-&gt;calculator-&gt;subtract(2, 2));
    $this-&gt;assertSame(6, $this-&gt;calculator-&gt;multiply(2,

(truncated - see the full file via the links below)

Read as markdown · JSON record · Browse the source repository

File tree — 3 files
phpunit-skill/SKILL.md
phpunit-skill/reference/advanced-patterns.md
phpunit-skill/reference/playbook.md

Related skills

Tags

test-automation mock-objects assertion-library test-isolation fixture-management coverage-reporting behavior-verification test-doubles