carlescliment/handy-tests-bundle
AppKernel and dependency injection container (DI) structure, requiring workarounds (e.g., standalone classes or custom integration layers).TableTruncator, FactoryGirl) are modular, allowing selective adoption.DatabaseMigrations or RefreshDatabase traits already handle test DB resets. This bundle’s TableTruncator could complement or replace these for fine-grained control (e.g., truncating specific tables post-test).laravel-shift/factory-boy) are more mature. This bundle’s FactoryGirl may appeal to teams already using Symfony’s Doctrine but could conflict with Laravel’s Eloquent conventions.Bundle system, EntityManager, and DI. Laravel would need:
EntityManager → Laravel’s DB or Eloquent).AppKernel equivalent).dev-master introduces instability. A stable release (e.g., v1.0) should be prioritized.Why Not Native Laravel Tools?
RefreshDatabase, Factories, or Mocker packages?WebTestCase or PHP-CS-Fixer integration needed for the project?Database Strategy
TableTruncator replace Laravel’s RefreshDatabase or serve as a supplemental tool for partial resets?beginTransaction()) vs. truncation?Performance Impact
Maintenance Burden
Team Adoption
spatie/laravel-test-factories, orchestra/testbench) that better fit the stack?Laravel Compatibility: The bundle is not natively Laravel-compatible but can be integrated via:
TableTruncator) and adapt them to use Laravel’s DB facade or Eloquent.AppServiceProvider (e.g., bind Symfony’s EntityManager to Laravel’s container).Testing Stack:
create() factories, actingAs()). Define clear boundaries to avoid redundancy.Assessment Phase:
RefreshDatabase, DatabaseTransactions).Proof of Concept (PoC):
TableTruncator using Laravel’s DB facade.// app/Services/TableTruncator.php
use Illuminate\Support\Facades\DB;
class TableTruncator {
public static function truncate(array $tables) {
foreach ($tables as $table) {
DB::statement("TRUNCATE TABLE $table");
}
}
}
EntityManager calls with Laravel’s Eloquent or DB where possible.Factory Integration:
FactoryGirl with Laravel’s factories (php artisan make:factory).laravel-shift/factory-boy as an alternative.Gradual Rollout:
RefreshDatabase with truncation where beneficial).TRUNCATE → Adapt for PostgreSQL/SQLite (e.g., DELETE + RESET IDENTITY).SoftDeletes) if present.EntityManager with Laravel’s Model::query() or DB facade.test environment check ('test' === $this->getEnvironment()) maps to Laravel’s APP_ENV=testing.Phase 1: Database Truncation
RefreshDatabase with TableTruncator for performance-critical tests.Phase 2: Entity Factories
FactoryGirl only if it provides unique value (e.g., Symfony-specific features).Phase 3: Advanced Features
dev-master) to avoid breaking changes.TableTruncator adapter) as part of the codebase.EntityManager issues) may require cross-stack knowledge.RefreshDatabase for large schemas but may lock tables.| Risk | Impact | Mitigation |
|---|---|---|
| Bundle breaks on Symfony update | Laravel integration fails | Pin bundle version; fork if critical. |
| Truncation corrupts test data | Flaky tests | Use transactions as a fallback. |
| Factory conflicts with Eloquent | Entity hydration issues | Validate factories against Laravel’s |
How can I help you explore Laravel packages today?