symplify/easy-testing
Utilities for easier PHP unit testing, focused on writing cleaner tests with less boilerplate. Provides helpers and base test cases commonly used in Symplify tools to streamline assertions, fixture handling, and test setup across projects.
Install the package via Composer: composer require --dev symplify/easy-testing. Despite being archived, it provides minimal boilerplate reduction out-of-the-box. Begin by extending Symplify\EasyTesting\PHPUnit\TestCase in your test classes to inherit shared setup logic (e.g., container bootstrapping, fixture management). For Laravel-specific needs, combine it with Laravel’s native traits like RefreshDatabase—this package doesn’t replace them but complements them. Run ./vendor/bin/phpunit and verify basic tests execute; check phpunit.xml for snapshot-related configuration if using snapshot assertions.
TestCase as a base class to centralize setUp()/tearDown() logic (e.g., resetting singleton state, mocking shared clients).SnapshotTestCase for deterministic assertions on dynamic outputs: assertMatchesSnapshot($result) for JSON, HTML, or CLI output. Ideal for regression testing of view rendering or API responses.KernelTestCase to bootstrap Laravel’s service container reliably—then inject dependencies directly via $this->app->make(Service::class).DatabaseTransactions or RefreshDatabase traits explicitly (e.g., use RefreshDatabase, TestCase;) since this package doesn’t override Laravel’s DB cleanup behavior.SNAPSHOT_DIR=tests/Snapshots) in phpunit.xml to keep snapshots organized.TestCase) locally if your project’s longevity depends on this functionality—e.g., paste the trait into tests/TestCase.php and maintain it yourself.SNAPSHOT_DIR path doesn’t exist. Pre-create tests/Snapshots/ and ensure write permissions. Use assertStringMatchesSnapshotFile() only for static fixtures—avoid for time-sensitive outputs.TestCase and Laravel’s CreatesApplication together—stick to KernelTestCase as the base if both container bootstrapping and DB interactions are needed.setUp() overrides) between this package and your primary testing stack. Run ./vendor/bin/phpstan analyse after setup to catch static analysis errors early.--testdox to see snapshot file names (e.g., ✔ My feature creates snapshot [foo_bar.test]). Compare mismatches manually—phpunit won’t auto-updated broken snapshots.How can I help you explore Laravel packages today?