bex / behat-magento2-init

提供从 Behat 访问 magento2 对象管理器,并允许临时更改 magento 配置设置

1.0.4 2017-01-06 11:09 UTC

This package is auto-updated.

Last update: 2024-09-11 13:15:53 UTC


README

Scrutinizer Code Quality Build Status

Behat-Magento2InitExtension 通过 BaseFixture 类提供对 magento2 对象管理器的访问,并在 Behat 运行时允许您临时更改 magento 配置设置。

安装

通过在您的 composer.json 中添加以下内容进行安装:

composer require --dev bex/behat-magento2-init

配置

behat.yml 中启用此扩展,如下所示:

default:
  extensions:
    Bex\Behat\Magento2InitExtension: ~

您可以这样配置 magento 启动文件的路径:

default:
  extensions:
    Bex\Behat\Magento2InitExtension:
      magento_bootstrap_path: /path/to/app/bootstrap.php

您可以这样更改 magento 配置设置:

default:
  extensions:
    Bex\Behat\Magento2InitExtension:
      magento_configs:
        -
          path: 'admin/security/use_form_key'
          value: 0
        -
          path: 'your_module/special_config/awesome_field'
          value: 'somevalue'
          scope_type: 'stores' # allowed values: default, stores, websites; default value: default
          scope_code: 'your_store_code' # the website or store code; default value: null

用法

当您运行 behat 时,此扩展将

  • 自动配置 magento2 对象管理器,因此它将在所有扩展了 Bex\Behat\Magento2InitExtension\Fixtures\BaseFixture 类的 fixture 类中可用(例如,请参阅 Bex\Behat\Magento2InitExtension\Fixtures\MagentoConfigManager)。
  • 在测试套件运行之前更改配置值,并在测试套件运行之后恢复原始配置值。