runroom-packages/testing
Testing utilities for Runroom's Laravel and PHP packages, offering reusable base test cases, helper traits, and assertions that simplify writing reliable unit and integration tests. Add it as a dev dependency to standardize test setup and cut boilerplate across projects.
runroom-packages/testing is a small, MIT-licensed helper library from Runroom aimed at reducing boilerplate when testing their Symfony/Laravel bundles and applications. It is not a framework itself—it is a grab-bag of base classes, traits, and assertion helpers that sit on top of PHPUnit.
Minimal steps:
Install as a dev dependency, never in production:
composer require --dev runroom-packages/testing
Open the src/ directory in vendor/runroom-packages/testing first. With 2 stars and a 0.01 score, README coverage is likely thin, and the authoritative documentation is the code itself. Look for:
TestCase or KernelTestCase subclass to extend.DatabaseTransactions, fixture loaders, mock builders).Constraint / assertion classes.Check the package composer.json for the minimum PHP and PHPUnit versions it targets—this determines whether it will slot into your existing test suite or fight it.
First use case: extend the provided base test case in one new test file and run a single test. Example shape (verify against actual source before adopting):
use Runroom\Testing\TestCase; // confirm namespace in vendor/
final class MyServiceTest extends TestCase
{
public function test_it_does_the_thing(): void
{
$this->assertTrue(true);
}
}
Run vendor/bin/phpunit --filter=MyServiceTest and confirm the base class boots without requiring extra environment configuration. If it does require config, that is your integration checklist.
Start with a single trivial test before wiring it into your real suite—this isolates setup problems from assertion problems.
1. Extending the base test case. The most common pattern is to make the package's TestCase the parent of your project's own abstract test case, so every test inherits its bootstrapping, container access, and helper methods:
// tests/TestCase.php in your project
abstract class TestCase extends \Runroom\Testing\TestCase
{
// project-wide setup here
}
This keeps a single seam for upgrading the package later.
2. Trait composition for focused helpers. Testing packages typically ship traits rather than forcing everything into the base class. Pull in only what a given test needs—database transactions, HTTP client helpers, fixture loading—so tests stay fast and explicit:
use Runroom\Testing\Traits\DatabaseTransactions;
final class RepositoryTest extends TestCase
{
use DatabaseTransactions;
}
3. Fixture-driven tests. If the package provides fixture loaders, prefer declarative fixtures over inline setUp() object construction. This keeps arrange blocks readable and makes it cheap to add data-provider variations later.
4. Data providers for edge cases. Combine any provided builders with PHPUnit data providers for boundary-heavy logic. This is where testing helpers earn their keep—reducing the per-case ceremony so you actually write the tenth case, not just the first.
5. CI integration. Because the package is dev-only, include it in your composer.lock and pin it. Cache vendor/ in CI keyed on the lock file so the extra dependency has effectively zero cost per run.
6. Wrap, don't scatter. When the package exposes something you use widely (an assertion, a mock factory), wrap it in a project-level helper. If you ever drop the dependency, you change one file rather than every test.
src/ and the package's own test suite—its tests are usually the best usage examples.composer.json constraints against your existing suite before adopting; a forced PHPUnit downgrade across a large project is rarely worth a convenience helper.require-dev. If it accidentally lands in require, you ship test scaffolding to production. Audit the composer.json diff after installing.autoload-dev config and regenerate the autoloader with composer dump-autoload.DATABASE_URL, or a specific filesystem layout. If bootstrapping fails in CI but passes locally, diff the environment first.TestCase is convenient but couples your whole suite to it. If you find yourself overriding many of its methods, wrap it instead.How can I help you explore Laravel packages today?