agentsclimarketplace

Phpunit

Skill G1Joshi/Agent-Skills/skills/testing/phpunit

PHPUnit PHP testing framework. Use for PHP testing.From its SKILL.md

Install
npx -y skills add G1Joshi/Agent-Skills --skill phpunit

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 12 stars12 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

SKILL.md

1.8 KB, 415 tokens by cl100k_base, as published. Nobody here has run it

PHPUnit

PHPUnit is the standard unit testing framework for the PHP ecosystem. Examples include usage in Laravel, Symfony, and WordPress.

When to Use

  • PHP Application: The industry standard.
  • TDD: Built-in support for mocking and code coverage.

Quick Start

<?php
use PHPUnit\Framework\TestCase;

final class StackTest extends TestCase
{
    public function testPushAndPop(): void
    {
        $stack = [];
        $this->assertEmpty($stack);

        array_push($stack, 'foo');
        $this->assertNotEmpty($stack);
        $this->assertEquals('foo', array_pop($stack));
    }
}

Core Concepts

Assertions

Methods like $this->assertTrue(), $this->assertSame(), $this->expectException().

Mock Objects

PHPUnit gives you control over the behavior of dependencies.

$stub = $this->createMock(SomeClass::class);
$stub->method('doSomething')->willReturn('foo');
$this->assertEquals('foo', $stub->doSomething());

Data Providers

Pass data to a test method (similar to parameterized tests).

#[DataProvider('additionProvider')]
public function testAdd(int $a, int $b, int $expected): void { ... }

Best Practices (2025)

Do:

  • Use Strict Assertions: $this->assertSame() checks types (===), whereas assertEquals is loose (==). Strict is safer.
  • Use Namespaces: Organize tests Tests\Unit\UserTest matching App\Models\User.
  • PHPUnit 11 features: Use the new attributes #[Test] instead of /** @test */ annotations if on PHP 8.2+.

Don't:

  • Don't test private methods: Test the public API. If a private method is complex, extract it to a new class.

References

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.