- How do I install k2gl/phpunit-fluent-assertions in a Laravel project?
- Install it as a dev dependency with Composer using composer require --dev k2gl/phpunit-fluent-assertions. No service provider or extra configuration is required because it augments PHPUnit directly. Once installed, you can start using the fluent assertion syntax in your existing PHPUnit test classes.
- Which PHPUnit versions does k2gl/phpunit-fluent-assertions support?
- The package is built on standard PHPUnit assertions and is intended for PHPUnit-based test suites, including the PHPUnit versions commonly used in Laravel projects such as PHPUnit 9 and 10. Check the composer.json constraints in the package repository for the exact supported PHPUnit version range before adding it to your project. Because it relies on PHPUnit-native failure handling, it should behave consistently with your existing assertion workflow.
- Does k2gl/phpunit-fluent-assertions conflict with Laravel's built-in testing helpers?
- There are no known conflicts with Laravel's built-in testing helpers because this package augments PHPUnit assertions rather than replacing Laravel's test utilities. You can continue using Laravel helpers such as HTTP and database assertions alongside the fluent PHPUnit API. Running your existing test suite after installation is still the best way to confirm compatibility in your specific application.
- Do I need any configuration after installing k2gl/phpunit-fluent-assertions?
- No configuration is required. The package is designed for zero-configuration use after Composer installation, so you can begin chaining assertions immediately. It adds a lightweight layer over PHPUnit without introducing runtime dependencies or framework coupling.
- How does the fluent API in k2gl/phpunit-fluent-assertions differ from standard PHPUnit assertions?
- Instead of repeating verbose $this->assert... calls throughout a test, the package lets you express expectations directly on the value under test in a single chainable expression. This makes tests read more like natural language while still using standard PHPUnit assertions and failure handling underneath. Existing PHPUnit assertions continue to work unchanged, so adoption can be incremental.
- Is k2gl/phpunit-fluent-assertions safe to use in production?
- The package is a test-time dependency and should be installed with --dev, so it does not affect your production runtime. It has no additional runtime dependencies and does not change Laravel application code. The main consideration is keeping it compatible with your PHPUnit version during test suite upgrades.
- What are doesNotThrow() and the inspect callback for throws() in k2gl/phpunit-fluent-assertions?
- Version 12.12.0 adds doesNotThrow() for asserting that a callback completes without throwing an exception, and an inspect callback for throws() so you can inspect the caught exception inside the fluent chain. These are additive features that make exception testing more expressive without altering existing behavior. Existing tests remain unaffected, and teams can adopt the new methods where they improve readability.
- Will upgrading k2gl/phpunit-fluent-assertions break my existing tests?
- The 12.11.0 to 12.12.0 release is a minor version bump with additive features, so existing test code should remain unaffected. You can continue using the package exactly as before and adopt doesNotThrow() or the inspect callback only where useful. As with any dependency, pinning versions and reviewing release notes is a sensible safeguard.
- What should I do if k2gl/phpunit-fluent-assertions becomes unmaintained?
- Because it is a dev-only dependency built on standard PHPUnit assertions, the fallback is straightforward: pin the package version you rely on and, if necessary, replace fluent chains with native PHPUnit assertions. Monitor PHPUnit major version upgrades, since those are the most likely point of incompatibility. Keeping tests readable with native assertions or custom helpers gives you a safe migration path.
- What are alternatives to k2gl/phpunit-fluent-assertions for fluent PHPUnit assertions?
- Alternatives include native PHPUnit assertions, Laravel's own testing helpers, custom assertion helper methods, or Pest's expect() API if your project uses Pest instead of plain PHPUnit. This package is aimed at teams that want a lightweight, PHPUnit-native fluent layer with no runtime dependencies. It is not a replacement for a full testing framework, so evaluate it against your existing test style and PHPUnit version.