- What is flarum/testing used for?
- flarum/testing provides reusable testing utilities for Flarum extensions. It boots a Flarum application for integration-style PHPUnit tests and supplies TestCase foundations plus helpers for database and API assertions. It is meant to reduce boilerplate so extension test suites stay consistent.
- How do I install flarum/testing for my Flarum extension?
- Install it with Composer as a development dependency, typically by running composer require --dev flarum/testing. It belongs in your extension's dev dependencies because it is only needed for automated tests. After installation, extend the provided TestCase foundations or use the helpers in your PHPUnit test classes.
- Which PHPUnit and Laravel versions does flarum/testing support?
- flarum/testing is built around standard PHPUnit workflows and a Laravel-based Flarum testing environment. Exact PHP, PHPUnit, and Illuminate/Laravel component constraints depend on the package release and your Flarum version. Check the package's composer.json and Packagist metadata before upgrading your test stack.
- How do I create a TestCase for a Flarum extension?
- Create a test class that extends the reusable TestCase foundation supplied by flarum/testing. That base class handles bootstrapping the Flarum application so your tests can focus on extension behavior. You can then add extension-specific setup and use the package's database and API assertion helpers.
- Does flarum/testing bootstrap a full Flarum application for tests?
- Yes, the package provides application bootstrapping for integration-style tests. This lets your PHPUnit tests run against a bootstrapped Flarum application instead of mocking every layer. It is useful when you need to verify extension behavior that depends on Flarum's container, database, or request lifecycle.
- How do I assert database state in Flarum extension tests?
- flarum/testing includes helpers for database assertions, so you can verify that your extension persisted or modified records as expected. Use them alongside your normal PHPUnit assertions after exercising the extension code. This keeps database checks consistent across your test suite.
- Can I test API endpoints with flarum/testing?
- Yes, the package supplies helpers for API assertions in extension tests. You can simulate requests and verify responses against the bootstrapped Flarum application. Combine these helpers with database assertions to cover full request-to-persistence behavior.
- How do I run flarum/testing tests in CI?
- Run your suite with PHPUnit, typically via vendor/bin/phpunit, after installing dependencies with Composer. Because flarum/testing bootstraps a Flarum application, your CI job needs the same PHP and database services your tests expect. Cache Composer dependencies and run the suite on each push or pull request.
- What are alternatives to flarum/testing for Flarum extension testing?
- Alternatives include writing your own Flarum application bootstrap and base TestCase, or using testing utilities shipped with Flarum core where they fit your needs. flarum/testing is focused on reducing that boilerplate with reusable foundations and assertion helpers. Evaluate it against your extension's PHPUnit setup and required Laravel components.
- Is flarum/testing maintained and safe for production test suites?
- flarum/testing is a development-only testing utility, so it does not ship in production code. Maintenance and release cadence should be checked on Packagist and the repository before adopting it for long-term suites. Pin a compatible version in require-dev and test upgrades against your Flarum version.