<commit_before>Feature: Step Definition Pattern
  In order to fix my mistakes easily
  As a step definitions developer
  I need to be able to use complex and weird patterns

  Scenario: Pattern with token at the start of the step
    Given a file named "features/bootstrap/FeatureContext.php" with:
      """
      <?php

      use Behat\Behat\Context\Context;

      class FeatureContext implements Context
      {
          /**
           * @Then :token should be :value
           */
          public function shouldBe($token, $value) {
          }
      }
      """
    And a file named "features/step_patterns.feature" with:
      """
      Feature: Step Pattern
        Scenario:
          Then 5 should be 10
          Then "foo" should be "bar"
      """
    When I run "behat -f progress --no-colors"
    Then it should pass with:
      """
      ..

      1 scenario (1 passed)
      2 steps (2 passed)
      """

  Scenario: Pattern with decimal point
    Given a file named "features/bootstrap/FeatureContext.php" with:
      """
      <?php

      use Behat\Behat\Context\Context;

      class FeatureContext implements Context
      {
          /**
           * @Then :token should have value of £:value
           */
          public function shouldHaveValueOf($token, $value) {
            echo $value;
          }
      }
      """
    And a file named "features/step_patterns.feature" with:
      """
      Feature: Step Pattern
        Scenario:
          Then 5 should have value of £10
          And 7 should have value of £7.2
      """
    When I run "behat -f pretty --no-colors"
    Then it should pass with:
      """
      Feature: Step Pattern

        Scenario:                         # features/step_patterns.feature:2
          Then 5 should have value of £10 # FeatureContext::shouldHaveValueOf()
            │ 10
          And 7 should have value of £7.2 # FeatureContext::shouldHaveValueOf()
            │ 7.2

      1 scenario (1 passed)
      2 steps (2 passed)
      """

  Scenario: Pattern with string including point
    Given a file named "features/bootstrap/FeatureContext.php" with:
      """
      <?php

      use Behat\Behat\Context\Context;

      class FeatureContext implements Context
      {
          /**
           * @Then :token should have value of :first.:second
           */
          public function shouldHaveValueOf($token, $first, $second) {
            echo $first . ' + ' . $second;
          }
      }
      """
    And a file named "features/step_patterns.feature" with:
      """
      Feature: Step Pattern
        Scenario:
          Then 5 should have value of two.three
          And 7 should have value of three.4
          And 7 should have value of 3.four
      """
    When I run "behat -f pretty --no-colors"
    Then it should pass with:
      """
      Feature: Step Pattern

        Scenario:                               # features/step_patterns.feature:2
          Then 5 should have value of two.three # FeatureContext::shouldHaveValueOf()
            │ two + three
          And 7 should have value of three.4    # FeatureContext::shouldHaveValueOf()
            │ three + 4
          And 7 should have value of 3.four     # FeatureContext::shouldHaveValueOf()
            │ 3 + four

      1 scenario (1 passed)
      3 steps (3 passed)
      """

  Scenario: Pattern with broken regex
    Given a file named "features/bootstrap/FeatureContext.php" with:
      """
      <?php

      use Behat\Behat\Context\Context;

      class FeatureContext implements Context
      {
          /**
           * @Then /I am (foo/
           */
          public function invalidRegex() {
          }
      }
      """
    And a file named "features/step_patterns.feature" with:
      """
      Feature: Step Pattern
        Scenario:
          Then I am foo
      """
    When I run "behat -f progress --no-colors"
    Then it should fail with:
      """
      [Behat\Behat\Definition\Exception\InvalidPatternException]
        The regex `/I am (foo/` is invalid:
      """

  Scenario: Pattern with default values
    Given a file named "features/bootstrap/FeatureContext.php" with:
      """
      <?php

      use Behat\Behat\Context\Context;

      class FeatureContext implements Context
      {
          /**
           * @Given only second :second
           */
          public function invalidRegex($first = 'foo', $second = 'fiz') {
            PHPUnit_Framework_Assert::assertEquals('foo', $first);
            PHPUnit_Framework_Assert::assertEquals('bar', $second);
          }
      }
      """
    And a file named "features/step_patterns.feature" with:
      """
      Feature: Step Pattern
        Scenario:
          Given only second "bar"
      """
    When I run "behat -f progress --no-colors"
    Then it should pass with:
      """
      .

      1 scenario (1 passed)
      1 step (1 passed)
      """<commit_msg>Scenario where definition parameter can be null<commit_after>Feature: Step Definition Pattern
  In order to fix my mistakes easily
  As a step definitions developer
  I need to be able to use complex and weird patterns

  Scenario: Pattern with token at the start of the step
    Given a file named "features/bootstrap/FeatureContext.php" with:
      """
      <?php

      use Behat\Behat\Context\Context;

      class FeatureContext implements Context
      {
          /**
           * @Then :token should be :value
           */
          public function shouldBe($token, $value) {
          }
      }
      """
    And a file named "features/step_patterns.feature" with:
      """
      Feature: Step Pattern
        Scenario:
          Then 5 should be 10
          Then "foo" should be "bar"
      """
    When I run "behat -f progress --no-colors"
    Then it should pass with:
      """
      ..

      1 scenario (1 passed)
      2 steps (2 passed)
      """

  Scenario: Pattern with decimal point
    Given a file named "features/bootstrap/FeatureContext.php" with:
      """
      <?php

      use Behat\Behat\Context\Context;

      class FeatureContext implements Context
      {
          /**
           * @Then :token should have value of £:value
           */
          public function shouldHaveValueOf($token, $value) {
            echo $value;
          }
      }
      """
    And a file named "features/step_patterns.feature" with:
      """
      Feature: Step Pattern
        Scenario:
          Then 5 should have value of £10
          And 7 should have value of £7.2
      """
    When I run "behat -f pretty --no-colors"
    Then it should pass with:
      """
      Feature: Step Pattern

        Scenario:                         # features/step_patterns.feature:2
          Then 5 should have value of £10 # FeatureContext::shouldHaveValueOf()
            │ 10
          And 7 should have value of £7.2 # FeatureContext::shouldHaveValueOf()
            │ 7.2

      1 scenario (1 passed)
      2 steps (2 passed)
      """

  Scenario: Pattern with string including point
    Given a file named "features/bootstrap/FeatureContext.php" with:
      """
      <?php

      use Behat\Behat\Context\Context;

      class FeatureContext implements Context
      {
          /**
           * @Then :token should have value of :first.:second
           */
          public function shouldHaveValueOf($token, $first, $second) {
            echo $first . ' + ' . $second;
          }
      }
      """
    And a file named "features/step_patterns.feature" with:
      """
      Feature: Step Pattern
        Scenario:
          Then 5 should have value of two.three
          And 7 should have value of three.4
          And 7 should have value of 3.four
      """
    When I run "behat -f pretty --no-colors"
    Then it should pass with:
      """
      Feature: Step Pattern

        Scenario:                               # features/step_patterns.feature:2
          Then 5 should have value of two.three # FeatureContext::shouldHaveValueOf()
            │ two + three
          And 7 should have value of three.4    # FeatureContext::shouldHaveValueOf()
            │ three + 4
          And 7 should have value of 3.four     # FeatureContext::shouldHaveValueOf()
            │ 3 + four

      1 scenario (1 passed)
      3 steps (3 passed)
      """

  Scenario: Pattern with broken regex
    Given a file named "features/bootstrap/FeatureContext.php" with:
      """
      <?php

      use Behat\Behat\Context\Context;

      class FeatureContext implements Context
      {
          /**
           * @Then /I am (foo/
           */
          public function invalidRegex() {
          }
      }
      """
    And a file named "features/step_patterns.feature" with:
      """
      Feature: Step Pattern
        Scenario:
          Then I am foo
      """
    When I run "behat -f progress --no-colors"
    Then it should fail with:
      """
      [Behat\Behat\Definition\Exception\InvalidPatternException]
        The regex `/I am (foo/` is invalid:
      """

  Scenario: Pattern with default values
    Given a file named "features/bootstrap/FeatureContext.php" with:
      """
      <?php

      use Behat\Behat\Context\Context;

      class FeatureContext implements Context
      {
          /**
           * @Given only second :second
           */
          public function invalidRegex($first = 'foo', $second = 'fiz') {
            PHPUnit_Framework_Assert::assertEquals('foo', $first);
            PHPUnit_Framework_Assert::assertEquals('bar', $second);
          }
      }
      """
    And a file named "features/step_patterns.feature" with:
      """
      Feature: Step Pattern
        Scenario:
          Given only second "bar"
      """
    When I run "behat -f progress --no-colors"
    Then it should pass with:
      """
      .

      1 scenario (1 passed)
      1 step (1 passed)
      """

  Scenario: Definition parameter with default null value
    Given a file named "features/bootstrap/FeatureContext.php" with:
    """
      <?php

      use Behat\Behat\Context\Context;

      class FeatureContext implements Context
      {
          /**
           * @Given I don't provide parameter
           * @Given I can provide parameter :param
           */
          public function parameterCouldBeNull($param = null) {
            PHPUnit_Framework_Assert::assertNull($param);
          }
      }
      """
    And a file named "features/step_patterns.feature" with:
      """
      Feature: Step Pattern
        Scenario:
          Given I don't provide parameter
      """
    When I run "behat -f progress --no-colors"
    Then it should pass with:
      """
      .

      1 scenario (1 passed)
      1 step (1 passed)
      """
{'fraction_non_alphanumeric': 0.09124053472936337, 'fraction_numerical': 0.009535383752453958, 'mean_word_length': 1.7138508371385084, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6185476', 'n_tokens_mistral': 2889, 'n_tokens_neox': 2800, 'n_words': 971}