Invoke before writing or modifying any .phpt test files. Provides Nette Tester conventions, Assert methods, and tester commands.
/plugin marketplace add nette/claude-code/plugin install nette@netteThis skill inherits all available tools. When active, it can use any tool Claude has access to.
We use Nette Tester for unit testing. Test files should have .phpt extension.
composer require nette/tester --dev
<?php
declare(strict_types=1);
use Tester\Assert;
use Nette\Assets\SomeClass;
require __DIR__ . '/../bootstrap.php';
test('SomeClass correctly does something', function () {
$object = new SomeClass();
$result = $object->doSomething();
Assert::same('expected value', $result);
});
test('SomeClass handles edge case properly', function () {
$object = new SomeClass();
$result = $object->handleEdgeCase();
Assert::true($result);
});
Key points:
test() function for each test casetest() should be a clear description of what is being testedtest() calls - the description parameter serves this purposeTo test if code correctly throws exceptions:
Assert::exception(
fn() => $mapper->getAsset('missing.txt'),
AssetNotFoundException::class,
"Asset file 'missing.txt' not found at path: %a%",
);
The Assert::exception() method:
If the entire test() block is to end with an exception, you can use testException():
testException('throws exception for invalid input', function () {
$mapper = new FilesystemMapper(__DIR__ . '/fixtures');<br>
$mapper->getAsset('missing.txt');
}, AssetNotFoundException::class, "Asset file 'missing.txt' not found at path: %a%");
# Run all tests
composer tester
# Run specific test file
vendor/bin/tester tests/common/Engine.phpt -s
# Run tests in specific directory
vendor/bin/tester tests/filters/ -s
Static Analysis & Code Quality using PHPStan
# Run PHPStan static analysis
composer phpstan
Use when working with Payload CMS projects (payload.config.ts, collections, fields, hooks, access control, Payload API). Use when debugging validation errors, security issues, relationship queries, transactions, or hook behavior.