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

Common Contexts Laravel Package

behat/common-contexts

Abandoned Behat 2.x add-on providing reusable subcontexts with extra steps/hooks. Includes contexts like SymfonyMailerContext, DoctrineFixturesContext, and SymfonyDoctrineContext for loading fixtures, purging DB, and resetting schema in Symfony-based suites.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Legacy System Modernization Roadmap: Justifies short-term adoption of this package for Behat 2.x projects while planning a phased migration to modern alternatives (e.g., Behat 3.x, Pest PHP, or Laravel’s native testing tools). Aligns with a cost-effective, incremental upgrade strategy for teams maintaining older Symfony 2.x/Laravel applications.
  • QA Automation Efficiency: Enables rapid test suite expansion for legacy projects by reducing the time to implement common testing patterns (e.g., database fixtures, email validation) without requiring custom development. Supports faster feedback loops in CI/CD pipelines for critical legacy features.
  • Build vs. Buy Decision: Avoids the development overhead of building custom Behat contexts from scratch for niche use cases (e.g., Symfony Mailer integration, Doctrine schema resets) in constrained timelines. Provides a low-cost, pre-built solution for teams without dedicated QA engineering resources.
  • Use Cases:
    • Legacy Feature Testing: Accelerates testing for Symfony 2.x modules in Laravel applications (e.g., legacy admin panels, payment gateways) that cannot be easily refactored.
    • Migration Testing: Validates data integrity during transitions from Symfony 2.x to Laravel by leveraging existing Behat 2.x test suites with minimal changes.
    • Compliance/Regulatory Testing: Speeds up implementation of audit trails, logging, or notification workflows (e.g., email alerts) in regulated industries where legacy systems are still in use.
    • Third-Party Integration Testing: Simplifies testing of external APIs or services that interact with legacy Symfony 2.x backends.

When to Consider This Package

  • Adopt if:

    • Your project is locked into Behat 2.x due to legacy constraints (e.g., no budget for a full upgrade, tight deadlines, or vendor dependencies).
    • You are maintaining a Symfony 2.x application integrated with Laravel (e.g., microservices, hybrid architectures) and need to test Symfony-specific components using Behat.
    • You require quick wins for test automation in a legacy codebase where writing custom contexts would delay releases.
    • Your team lacks the resources to build or maintain custom Behat contexts for common scenarios (e.g., fixtures, mailers).
    • You are evaluating migration paths and need a temporary solution to stabilize existing test suites while planning a long-term upgrade.
  • Avoid if:

    • You are using Behat 3.x+, Pest PHP, or Laravel’s native testing tools (e.g., create(), assertDatabaseHas()). Modern alternatives (e.g., behat/symfony-extension, spatie/laravel-test-tools) are actively maintained and Laravel-compatible.
    • Your project is greenfield or uses Laravel’s Eloquent/DBAL without Symfony dependencies. The package’s Symfony-specific contexts (e.g., SymfonyMailerContext) are irrelevant.
    • You prioritize long-term maintainability over short-term gains. The package’s abandoned status introduces technical debt and security risks.
    • Your team has the capacity to build custom contexts or migrate to a supported testing framework (e.g., Pest PHP, which is faster and Laravel-first).
    • You need active support, bug fixes, or compatibility with modern PHP/Laravel versions (e.g., PHP 8.x, Laravel 9+).

How to Pitch It (Stakeholders)

For Executives: "This package helps us reduce QA bottlenecks for our legacy Symfony 2.x modules by providing pre-built Behat contexts for common testing tasks—like database resets and email validation—without hiring additional engineers. It’s a short-term fix to stabilize our test coverage while we plan a phased migration to modern tools (targeted for Q3). The trade-off? Minimal upfront cost, but we’ll need to replace it in 6–12 months. For example, it could cut the time to implement a new payment-processing test suite from 2 weeks to 2 days—justifying the risk for legacy-critical features."

For Engineering/DevOps: *"Why Use It:

  • Saves time on boilerplate code for fixtures, mailers, and Doctrine schema resets in Behat 2.x.
  • Works out-of-the-box for Symfony 2.x + Behat 2.x (e.g., our legacy-inventory project).
  • Zero dependencies beyond Behat 2.x itself.

Key Caveats:

  • Not Laravel-native: The package assumes Symfony’s service container and Doctrine ORM v2.x. We’d need to mock or adapt these for Laravel (e.g., replace SymfonyMailerContext with Laravel’s Mail::fake()).
  • Abandoned: No updates for Behat 3.x+. We’ll need to migrate away when we upgrade Behat.
  • Limited scope: Only covers Symfony/Doctrine use cases—custom logic still requires manual work.

Recommendation: Use this only for legacy projects where upgrading Behat is not feasible. Pair it with a migration plan to modern alternatives (e.g., Pest PHP, spatie/laravel-test-tools). Example:

// Legacy Symfony 2.x Behat context (temporary)
$this->useContext('symfony_doctrine_context', new SymfonyDoctrineContext());

→ Replace with:

// Modern Laravel alternative
use Illuminate\Support\Facades\Artisan;
Artisan::call('migrate:fresh');

For QA/Test Teams: *"This package cuts your workload by handling repetitive tasks like:

  • Loading fixtures: Use DoctrineFixturesContext to seed test data in one line.
  • Resetting the DB: SymfonyDoctrineContext rebuilds the schema before scenarios.
  • Testing emails: SymfonyMailerContext validates mailers without custom code.

How to Start:

  1. Add to composer.json (temporarily):
    "behat/common-contexts": "dev-main"
    
  2. Extend your FeatureContext (see README).
  3. Use @BeforeScenario hooks for automation.

Note: This is a stopgap. Flag any issues—we’ll replace it when we upgrade Behat. For new projects, use Laravel’s built-in testing tools instead."*

For Technical Leads: *"Risk Assessment:

  • Integration Risk: High. The package is not Laravel-compatible and requires workarounds (e.g., container mocking, Doctrine adapters).
  • Maintenance Risk: Critical. No updates mean security/bug fixes are your responsibility.
  • Migration Cost: Medium. Replacing it later will require rewriting contexts or switching frameworks.

Mitigation Plan:

  1. Scope Limitation: Restrict use to legacy Symfony 2.x modules only.
  2. Document Workarounds: Track hacks (e.g., container mocking) for future cleanup.
  3. Set Deprecation Date: Replace with modern tools by [target date].
  4. Explore Alternatives: Evaluate spatie/laravel-test-tools or Pest PHP for long-term gains.

Example Workaround for Laravel:

// Replace SymfonyDoctrineContext with Laravel’s Artisan
use Illuminate\Support\Facades\Artisan;

BeforeScenario(function () {
    Artisan::call('migrate:fresh --env=testing');
});
```"
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.
craftcms/url-validator
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony