friends-of-behat/mink-browserkit-driver
friends-of-behat/mink-browserkit-driver is a Symfony BrowserKit driver for Mink, a behavioral testing framework. It enables headless browser testing (via Symfony’s BrowserKit) for PHP applications, making it ideal for:
symfony/http-client or symfony/browser-kit (if used) can interface with BrowserKit.minkphp/Mink + this driver) could be built to test HTTP routes, sessions, or middleware.symfony/browser-kit:^4.4|^5.0|^6.0), which Laravel does not include by default.minkphp/mink) as a wrapper.laravel/browser-kit-testing or laravel/dusk (for JS-heavy apps).refreshDatabase()).| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Symfony Dependency | High | Abstract BrowserKit behind a Laravel facade or use a micro-service for testing. |
| Limited Laravel Ecosystem | High | Build a custom Mink adapter or use this package only for non-JS HTTP routes. |
| Maintenance Overhead | Medium | Fork the package if critical fixes are needed (MIT license allows this). |
| False Positives/Negatives | Medium | Combine with Laravel’s HttpTests for broader coverage. |
| Performance | Low | BrowserKit is fast, but not for JS-heavy apps. |
Testing Scope:
Architecture Trade-offs:
Toolchain Integration:
Long-Term Viability:
paratest/php-mink) justified?refreshDatabase().Assess Current Testing Stack:
POST → Mink-friendly. A test clicking a button that triggers AJAX → not Mink-friendly.Dependency Setup:
composer require minkphp/mink friends-of-behat/mink-browserkit-driver symfony/browser-kit
behat/behat for BDD-style tests (though Laravel’s Pest is more idiomatic).Laravel Integration Layers:
Mink\Driver\DriverInterface to wrap Laravel’s HttpClient or BrowserKit.class LaravelBrowserKitDriver implements DriverInterface {
public function visit($url) {
return Laravel\BrowserKit\TestCase::call('GET', $url);
}
// ... other methods
}
symfony/http-client to initialize BrowserKit:
use Symfony\Component\BrowserKit\HttpBrowser;
$client = new HttpBrowser();
$client->request('GET', '/login');
Test Conversion:
use Mink\Mink;
use FriendsOfBehat\MinkBrowserKitDriver\BrowserKitDriver;
$mink = new Mink(new BrowserKitDriver());
$session = $mink->getSession();
$session->visit('/login');
| Component | Compatibility Notes |
|---|---|
| Laravel 8+ | ✅ PHP 7.4+ support aligns. |
| Symfony 4.4+ | ✅ Required by the package. |
| Behat | ⚠️ Optional; can use Mink standalone with PHPUnit/Pest. |
| Laravel Dusk | ❌ Incompatible (Dusk uses ChromeDriver). |
| Pest | ✅ Can integrate via custom test classes. |
| Database | ❌ No native support for Laravel’s refreshDatabase(). Requires manual setup. |
Phase 1: Proof of Concept (2-4 weeks)
LaravelBrowserKitDriver).Phase 2: Hybrid Integration (4-6 weeks)
beforeEach for Mink setup).assertSessionHas() for Laravel sessions).Phase 3: Full Adoption (Ongoing)
| Task | Effort | Owner |
|---|---|---|
| Dependency Updates | Low | DevOps |
| Test Maintenance | Medium | QA/Dev Team |
| Debugging Failures | High | Backend Dev |
| CI Integration | Medium | DevOps |
How can I help you explore Laravel packages today?