與Storybdd擴展Sylius:增強產品庫存管理 >
密鑰概念:
我們創建一個behat功能文件():>
運行此操作會揭示缺失的步驟。 我們創建一個自定義上下文( 我們將此上下文配置在 , >最後,我們擴展了產品變體形式以允許修改重新排序級別。這涉及創建一個表單擴展名( 結論:
使用behat實施Storybdd測試
features/product/managing_products/browsing_products_with_inventory.feature
):<code class="language-gherkin">@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</code>
src/Sylius/Behat/Context/Ui/Admin/ManagingProductsInventoryContext.php
和<code class="language-php"><?php
// ... (imports) ...
class ManagingProductsInventoryContext implements Context
{
// ... (IndexPageInterface injection and methods) ...
}</code>
,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中文網其他相關文章!