📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials PHPUnit Testing Behat BDD Testing

Behat BDD Testing

5 min read
Use PHP CS Fixer, CodeSniffer, PHPStan, and Rector to enforce code quality and style.

BDD with Behat

composer require --dev behat/behat

# features/registration.feature
Feature: User Registration
  Scenario: Successful registration
    Given I am on the registration page
    When I fill in email with "alice@example.com"
    And I press "Register"
    Then I should see "Welcome"

# FeatureContext.php
class FeatureContext implements Context {
    #[When("I fill in :field with :value")]
    public function fillIn(string $field, string $value): void {
        $this->form[$field] = $value;
    }
}