在我的 Behat 场景中传递强制参数

Pass through a mandatory parameters in my Behat scenario

我正在尝试确定如何传递遵循我的 Behat 功能文件中定义的路线所需的强制参数。

这是我的场景:

Scenario: I should be able to create a cars asset
    Given I am on the ayrshireminis_cars_asset_create page
    When I submit a "ayrshireminis.cars.asset.type" form with values:
        | name               | type | position | active |
        | Cars Info Doc      | PDF  | 1        | 1      |
    Then The form should be valid

这是错误:

Given I am on the ayrshireminis_cars_asset_create page Some mandatory parameters are missing ("categoryId") to generate a URL for route "ayrshireminis_cars_asset_create". (Symfony\Component\Routing\Exception\MissingMandatoryParametersException)

很清楚为什么我会收到此错误,因为我的路由配置如下:

ayrshireminis_cars_asset_create:
    pattern: /category/{categoryId}/asset/new/

如何通过categoryId

我发现我从错误的角度看这个问题,最后我是这样构建测试场景的:

Scenario: Submitting a valid cars asset form
    When I submit a "ayrshireminis.cars.cars_asset.type" form with values:
        | name               | type | position | active |
        | Cars Info Doc      | pdf  | 1        | 1      |
    Then  the form should be valid
    And   the cars entity form entity should have the following values
        | name               | type | position | active |
        | Cars Info Doc      | pdf  | 1        | 1      |
    And   the cars entity form entity should be persisted correctly