Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Phpunit Extras

Phpunit Extras Laravel Package

rybakit/phpunit-extras

Extend PHPUnit with custom annotations, placeholders, requirements, and expectations. Build and integrate your own @tags, version/package/expression-based requirements, and reusable expectation helpers. Optional support for composer/semver, package-versions, and symfony/expression-language.

View on GitHub
Deep Wiki
Context7

Custom annotations and expectations for PHPUnit.

Frequently asked questions about Phpunit Extras
What is rybakit/phpunit-extras used for in Laravel testing?
It extends PHPUnit with custom annotations, placeholders, requirements, and expectations. In Laravel projects it lets you add reusable test metadata and assertion helpers without changing application code. It operates as a testing utility layer and works alongside Laravel's built-in testing helpers.
How do I install rybakit/phpunit-extras in a Laravel project?
Install it as a Composer dev dependency with composer require --dev rybakit/phpunit-extras. Optional features need extra packages: composer/semver for version requirements, ocramius/package-versions for package requirements, and symfony/expression-language for expression-based features. Then extend PHPUnitExtras\TestCase or use the provided trait in your tests.
Does rybakit/phpunit-extras support my Laravel and PHPUnit versions?
The package is a PHPUnit extension layer, so its compatibility follows PHPUnit rather than Laravel version numbers. It is intended for Laravel projects that use PHPUnit and does not alter Laravel's runtime or testing helpers. Check the package's PHPUnit constraints for your specific Laravel stack.
How do I create custom PHPUnit annotations with rybakit/phpunit-extras?
You can build custom @tags by defining annotation classes and processors, then integrating them through the base test case or trait. The package provides patterns for requirements, placeholders, and expectations. This lets you encode environment or package conditions directly in test docblocks.
What are annotation placeholders like %target_method% in rybakit/phpunit-extras?
Placeholders are dynamic values resolved from the test context and inserted into annotations. Built-in placeholders include TargetClass, TargetMethod, and TmpDir. You can use them to avoid hardcoding class or method names in custom annotations.
Can I use rybakit/phpunit-extras expectations with Laravel assertions?
Yes, expectations are reusable helpers that complement Laravel's assert methods. They run within PHPUnit tests and do not interfere with helpers such as assertDatabaseHas. You can define expectation helpers for repeated checks in your test suite.
Do I need composer/semver or symfony/expression-language for rybakit/phpunit-extras?
Only if you use those specific features. composer/semver is for version-related requirements, ocramius/package-versions is for the package requirement, and symfony/expression-language is for expression-based requirements or expectations. The core annotations and expectations work without them.
Is rybakit/phpunit-extras safe for production Laravel applications?
It is a dev-only testing utility and should be installed with --dev. It does not affect Laravel's runtime or production code. Production risk is minimal when it remains outside production dependencies.
How do I test and validate custom annotations with rybakit/phpunit-extras in CI?
Add the package as a dev dependency and run your normal PHPUnit suite in CI. If you use optional plugins, ensure Composer 2.1 or newer and configure allow-plugins for ocramius/package-versions where needed. Existing tests should remain unaffected because the package is non-breaking and isolated from application logic.
Is rybakit/phpunit-extras maintained, and what alternatives exist for custom PHPUnit annotations?
Alternatives include writing PHPUnit extensions directly or using custom attributes in newer PHPUnit versions. Laravel's own testing helpers cover many common assertions but not custom docblock annotations. rybakit/phpunit-extras is useful when you want reusable annotations and expectation helpers without building the extension plumbing yourself, and you should monitor its repository for maintenance updates.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
htinlynn/genius-helper
maco-studios/hephaestus
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator