Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Functional Test Bundle Laravel Package

liip/functional-test-bundle

Symfony bundle providing base classes and helpers for functional tests, plus a DI-aware mock builder for unit tests. Includes tools for command testing, logged clients, query counting, examples, and parallel test runs.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Symfony Alignment: The package is a Symfony Bundle, making it a native fit for Laravel applications only if they are part of a Symfony-based ecosystem (e.g., Laravel + Symfony components via bridges like symfony/http-client, symfony/process, or symfony/dependency-injection). For pure Laravel, this is not directly applicable without significant abstraction layers.
  • Test-Driven Focus: The bundle provides functional test utilities (e.g., pre-authenticated clients, service mocking, query counters) that align with Symfony’s testing philosophy. Laravel’s built-in testing tools (phpunit, laravel/testcase) already cover ~80% of these use cases, but the bundle adds DI-aware mocking and Symfony-specific conveniences (e.g., WebTestCase extensions).
  • Laravel Gaps: Laravel lacks:
    • A built-in WebTestCase base class with pre-authenticated clients.
    • Dependency Injection (DI) mocking helpers for service containers (Laravel uses the Service Container, not Symfony’s DI).
    • Query counting for performance testing (Laravel has DB::enableQueryLog(), but no bundled assertion helpers).

Integration Feasibility

  • Symfony Dependency: The bundle requires Symfony components (e.g., symfony/browser-kit, symfony/security). Laravel would need:
    • Symfony HTTP Client (symfony/http-client) for Client simulations.
    • Symfony Security (symfony/security) for authentication helpers.
    • Symfony DI (symfony/dependency-injection) for mocking (Laravel’s container is incompatible).
  • Workarounds:
    • Option 1: Use only the test utilities (e.g., QueryCounter) via standalone classes (extract logic from the bundle).
    • Option 2: Wrap Symfony components in Laravel-compatible facades (e.g., SymfonyClient facade for BrowserKit).
    • Option 3: Replace with Laravel-native alternatives (e.g., laravel/browsershot for headless testing, mockery for DI mocking).
  • Migration Complexity: High for full adoption due to Symfony dependencies. Low for selective use (e.g., copying QueryCounter logic).

Technical Risk

  • Dependency Bloat: Adding Symfony components increases bundle size and couples Laravel to Symfony’s ecosystem, complicating future updates.
  • Maintenance Overhead: The bundle is last updated in 2026, but Laravel’s testing tools evolve faster (e.g., Pest PHP, Laravel 11’s test improvements).
  • Breaking Changes: Symfony’s testing APIs (e.g., WebTestCase) may diverge from Laravel’s HttpTestCase, requiring dual maintenance.
  • Key Risks:
    • Authentication: Laravel’s actingAs() is simpler than Symfony’s loginClient().
    • Mocking: Laravel’s partialMock() or Mockery may suffice; Symfony’s DI mocking is niche.
    • Performance: Query counting could be implemented via Laravel’s DB::listen().

Key Questions

  1. Why not use Laravel’s built-in testing tools?

    • Does the team need Symfony-specific features (e.g., QueryCounter, advanced DI mocking)?
    • Are there gaps in Laravel’s testing that this bundle fills (e.g., pre-authenticated clients for complex auth setups)?
  2. Symfony Integration Strategy:

    • Will the app mix Symfony components (e.g., for APIs)? If yes, this bundle could be useful.
    • Is the team open to dual testing stacks (Symfony for functional tests, Laravel for unit tests)?
  3. Alternatives Evaluation:

    • Pest PHP: Offers modern testing syntax with Laravel integration.
    • Laravel Test Helpers: Extend HttpTestCase with custom assertions.
    • Standalone Tools: Use symfony/browser-kit directly without the bundle.
  4. Long-Term Viability:

    • Will the bundle remain compatible with future Laravel/Symfony versions?
    • Is the maintenance burden justified by the features?

Integration Approach

Stack Fit

  • Laravel Core: Low compatibility due to Symfony dependencies.
    • Client Simulation: Laravel’s HttpTestCase + Http::fake() can replace BrowserKit.
    • Authentication: actingAs() is Laravel-native; Symfony’s loginClient() is redundant.
    • Mocking: Laravel’s Mockery or partialMock() covers DI mocking.
  • Symfony Components: Partial fit if the app already uses:
    • symfony/http-client (for API testing).
    • symfony/security (for complex auth).
    • symfony/dependency-injection (for advanced service mocking).
  • Recommended Stack:
    Feature Laravel Native Symfony Bundle Recommendation
    Functional Tests HttpTestCase WebTestCase Use Laravel’s (simpler)
    Pre-Auth Clients actingAs() loginClient() Use Laravel’s
    Service Mocking Mockery DI Mock Builder Use Mockery or partialMock()
    Query Counting DB::listen() QueryCounter Implement custom assertion
    Command Testing Artisan::call() runCommand() Use Laravel’s

Migration Path

  1. Assessment Phase:

    • Audit existing tests to identify Symfony-specific gaps (e.g., need for QueryCounter).
    • Benchmark Laravel-native alternatives (e.g., Pest PHP for faster test writing).
  2. Pilot Integration:

    • Option A: Use selective bundle features (e.g., copy QueryCounter logic into a Laravel service).
    • Option B: Wrap Symfony components in Laravel facades (e.g., SymfonyClient for BrowserKit).
    • Option C: Replace with Laravel tools (e.g., laravel/browsershot for headless testing).
  3. Full Adoption (High Risk):

    • Step 1: Add Symfony components via Composer:
      composer require symfony/browser-kit symfony/security symfony/dependency-injection
      
    • Step 2: Create a Laravel-compatible test base class extending WebTestCase:
      use Liip\FunctionalTestBundle\Test\WebTestCase as SymfonyWebTestCase;
      use Illuminate\Foundation\Testing\TestCase;
      
      abstract class LaravelWebTestCase extends TestCase {
          protected function makeClient(array $credentials = null) {
              return SymfonyWebTestCase::makeClient($credentials);
          }
      }
      
    • Step 3: Gradually migrate tests to use the new base class.
  4. Fallback Plan:

    • If integration fails, extract only needed logic (e.g., QueryCounter) into standalone classes.

Compatibility

  • Laravel 10/11: Partial compatibility (Symfony 6.4+ required; Laravel uses Symfony 6.2).
  • PHP 8.1+: The bundle supports PHP 8.1; Laravel 10+ requires PHP 8.1.
  • Testing Frameworks:
    • PHPUnit: Works (bundle uses PHPUnit).
    • Pest: May require adapters for WebTestCase methods.
  • Authentication Providers:
    • Laravel’s actingAs() works with database users, while Symfony’s loginClient() supports UserInterface. Custom adapters may be needed.

Sequencing

  1. Phase 1: Low-Risk Adoption (1-2 weeks):

    • Use bundle only for missing features (e.g., QueryCounter).
    • Implement Laravel wrappers for Symfony components.
  2. Phase 2: Pilot Testing (2-3 weeks):

    • Migrate 1-2 test suites to use the bundle.
    • Compare test speed, readability, and maintenance vs. Laravel-native tools.
  3. Phase 3: Full Integration (3-4 weeks):

    • Standardize on a hybrid approach (e.g., bundle for functional tests, Laravel for unit tests).
    • Document Symfony-Laravel test conventions.
  4. Phase 4: Optimization:

    • Replace Symfony dependencies with Laravel-native solutions where possible.
    • Deprecate unused bundle features.

Operational Impact

Maintenance

  • Bundle Updates:
    • Risk: Symfony 7+ may break Laravel compatibility.
    • Mitigation: Pin to a stable version (e.g., v2.0) and avoid major upgrades.
  • Laravel-Specific Overrides:
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui