matthiasnoback/doctrine-dbal-test-service-provider
createSchema(), aligning with Laravel’s migration-first philosophy but tailored for tests. This reduces flakiness from implicit schema assumptions.PHPUnit + Laravel\Testing\TestCase.TestCaseWithDoctrineDbalConnection and implement createSchema().DatabaseTransactions, RefreshDatabase) by scoping its use to unit tests (e.g., repository/DAO layers) while leaving feature tests to Laravel’s ecosystem.Observers, Model::boot()).RefreshDatabase, this package destroys and recreates the schema per test, which may not match expectations for tests involving transactions.doctrine/dbal (used by Laravel) or matthiasnoback/phpunit-test-service-container. Pin versions explicitly in composer.json.RefreshDatabase or supplement it? (e.g., use for unit tests, Laravel’s tools for feature tests).Pest or Laravel\Testing\TestCase. If using Pest, consider wrapping the trait in a custom Pest plugin.Illuminate\Database\Connection), but tests must avoid Eloquent.RefreshDatabase.DatabaseMigrations or DatabaseTransactions.UserRepositoryTest).RefreshDatabase for these layers.TestCase and conditionally use the trait:
use Illuminate\Foundation\Testing\TestCase as LaravelTestCase;
use Noback\PHPUnitTestServiceContainer\PHPUnit\TestCaseWithDoctrineDbalConnection;
abstract class BaseTest extends LaravelTestCase
{
use TestCaseWithDoctrineDbalConnection; // Only for DBAL tests
}
SchemaTool).doctrine/dbal (Laravel already includes this).Model::create(), factory().$connection->insert()), query builder (DB::connection()->table()), or custom repositories.RefreshDatabase for unit tests in favor of this package.doctrine/dbal and Noback’s container for breaking changes.composer.json to avoid surprises.DatabaseMigrations) may no longer be needed but require migration.createSchema() is misconfigured.--parallel flag for faster suites.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Schema definition errors | Tests fail silently or with unclear errors | Use Schema validation tools or CI checks. |
| DBAL version conflicts | Tests pass locally but fail in CI | Pin doctrine/dbal version in composer.json. |
| Eloquent usage in tests | Tests break or behave unexpectedly | Static analysis to detect Eloquent calls. |
| Large schema definitions | Slow test execution | Optimize schemas; use shared base schemas. |
| Missing constraints/indexes | Tests pass but fail in production | Mirror production constraints in test schemas. |
| CI environment DBAL misconfig | Tests fail in CI with real databases | Configure CI to use SQLite by default. |
How can I help you explore Laravel packages today?