与Storybdd扩展Sylius:增强产品库存管理 >
密钥概念:
我们创建一个behat功能文件():>
运行此操作会揭示缺失的步骤。 我们创建一个自定义上下文( 我们将此上下文配置在 , >最后,我们扩展了产品变体形式以允许修改重新排序级别。这涉及创建一个表单扩展名( 结论:
使用behat实施Storybdd测试
features/product/managing_products/browsing_products_with_inventory.feature
):@managing_inventory
Feature: Browsing products with inventory
In order to manage my shop merchandise
As an Administrator
I want to be able to browse products
Background:
Given the store operates on a single channel in "United States"
And the store has a product "Kubus"
And it comes in the following variations:
| name | price |
| Kubus Banana | .00 |
| Kubus Carrot | .00 |
And there are 3 units of "Kubus Banana" variant of product "Kubus" available in the inventory
And there are 5 units of "Kubus Carrot" variant of product "Kubus" available in the inventory
And I am logged in as an administrator
@ui
Scenario: Browsing defined products with inventory
Given the "Kubus Banana" product variant is tracked by the inventory
And the "Kubus Carrot" product variant is tracked by the inventory
When I want to browse products
Then I should see that the product "Kubus" has 8 on hand quantity
src/Sylius/Behat/Context/Ui/Admin/ManagingProductsInventoryContext.php
和<?php
// ... (imports) ...
class ManagingProductsInventoryContext implements Context
{
// ... (IndexPageInterface injection and methods) ...
}
src/Sylius/Behat/Resources/config/services/contexts/ui.xml
)是必要的。src/Sylius/Behat/Resources/config/suites/ui/inventory/managing_inventory.yml
>
doctrine:database:create
实施丢失的步骤涉及使用Sylius的doctrine:schema:create
与产品列表进行交互,并断言以验证库存列的存在和数据。 我们还需要更新sylius网格配置(doctrine:schema:update
)以添加“库存”列并创建一个自定义模板(src/AppBundle/Form/Type/Extension/ProductVariantTypeExtension.php
),将其配置为服务(src/AppBundle/Resources/config/services.yml
),并更新相关模板(app/Resources/SyliusAdminBundle/views/ProductVariant/Tab/_details.html.twig
)。
以上是升级Sylius的TDD方式:探索Behat的详细内容。更多信息请关注PHP中文网其他相关文章!