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

Mink Driver Testsuite Laravel Package

friends-of-behat/mink-driver-testsuite

Fork of Mink DriverTestsuite updated for PHP >=7.4, Symfony >=4.4, and PHPUnit ^8.0. Use it to run Mink driver compliance tests with modern Symfony/PHP stacks. Documentation follows the original minkphp/driver-testsuite repo.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation Add the package via Composer:

    composer require --dev friends-of-behat/mink-driver-testsuite
    

    Ensure your phpunit.xml includes the test suite autoloader:

    <autoload>
        <classmap>
            <dir>vendor/friends-of-behat/mink-driver-testsuite</dir>
        </classmap>
    </autoload>
    
  2. First Use Case Use the test suite to validate a custom Mink driver (e.g., Selenium, Guzzle, or a headless browser like Playwright). Example:

    use FriendsOfBehat\DriverTestSuite\TestSuite;
    
    $testSuite = new TestSuite();
    $testSuite->run(new \Mink\Driver\Selenium2Driver($capabilities));
    

    Run via PHPUnit:

    ./vendor/bin/phpunit --testsuite DriverTestSuite
    

Implementation Patterns

Workflow Integration

  1. Driver Validation

    • Use the test suite to verify a custom Mink driver’s compliance with Mink’s expected behavior (e.g., form submission, JavaScript execution, or element interaction).
    • Example: Test a Playwright driver by extending the suite:
      use FriendsOfBehat\DriverTestSuite\TestSuite;
      use FriendsOfBehat\DriverTestSuite\Tests\DriverTestCase;
      
      class PlaywrightDriverTest extends DriverTestCase {
          protected function createDriver() {
              return new \Mink\Driver\PlaywrightDriver();
          }
      }
      
  2. CI/CD Hooks

    • Integrate into Laravel’s phpunit.xml to run tests on every git push:
      <testsuites>
          <testsuite name="Driver Tests">
              <directory>./vendor/friends-of-behat/mink-driver-testsuite/tests</directory>
          </testsuite>
      </testsuites>
      
  3. Custom Test Cases

    • Extend DriverTestCase to add Laravel-specific assertions (e.g., CSRF token handling):
      public function testCsrfTokenHandling() {
          $this->getSession()->visit('/login');
          $this->assertSession()->fieldEquals('csrf_token', csrf_token());
      }
      

Gotchas and Tips

Pitfalls

  1. Symfony Dependency

    • The package requires Symfony components (e.g., HttpFoundation). If your project lacks them, install via:
      composer require symfony/http-foundation
      
  2. PHPUnit Version Mismatch

    • Ensure PHPUnit ^8.0 is installed. Conflicts may arise with Laravel’s default PHPUnit version (e.g., ^9.0). Pin versions in composer.json:
      "require-dev": {
          "phpunit/phpunit": "^8.5"
      }
      
  3. Driver-Specific Quirks

    • Some drivers (e.g., Selenium) require additional setup (e.g., Docker, WebDriver binaries). Document these in README.md:
      ## Driver Setup
      - Install ChromeDriver: `brew install chromedriver`
      - Configure Selenium in `.env`:
      
      MINK_DRIVER=selenium2 SELENIUM_BROWSER=chrome
      
      

Debugging Tips

  • Verbose Output: Run tests with -v to diagnose failures:
    ./vendor/bin/phpunit -v --testsuite DriverTestSuite
    
  • Isolation: Test drivers in a clean environment (e.g., Docker) to avoid conflicts with Laravel’s app state.

Extension Points

  • Custom Assertions: Override DriverTestCase methods to add Laravel-specific logic (e.g., auth checks).
  • Parallel Testing: Use PHPUnit’s parallelization for faster feedback:
    <phpunit parallel="true" />
    
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.
calmfox/watch-sylius
damienfern/grpc-symfony-bundle
atoolo/index-bundle
atoolo/genai-bundle
coprotoai/laravel-ticket
davidjln/llm-carbon-bundle
cryonighter/valid-request-bundle
coolms/taxonomy-bundle
coolms/field-bundle
articulate-orm/symfony
aaix/laravel-tall-architect
ephoto/akeneo-connector
emmanuelballery/eb-plantumlbundle
emielburgman/symfony-visitor-beacon
emielburgman/symfony-visit-storage
emielburgman/symfony-security-headers
emielburgman/symfony-log-viewer
emarref/xdebug-bundle
emarref/pubnub-bundle
elriseio/finance-money-bundle