irs / behat-magento-extension
Behat 扩展,用于恢复 Magento 至所需状态。
dev-master
2013-04-11 07:59 UTC
Requires
- php: >=5.4.7
- behat/behat: 2.4.*
- irs/magento-initializer: dev-master
- symfony/console: >=2.0,<2.3-dev
- symfony/yaml: >=2.2,<2.3-dev
Requires (Dev)
- phpunit/phpunit: 3.7.*
This package is auto-updated.
Last update: 2024-09-22 20:39:00 UTC
README
此扩展定义了 Behat 钩子,可用于在特征上下文中使用,允许将 Magento 恢复到特定状态。
安装
要使用 Composer 安装此扩展,请在您的 composer.json 中添加以下行:
{ "require": { "irs/behat-magento-extension": "dev-master" } }
然后运行 composer install。之后,要启用扩展,请将以下行添加到 behat.yml:
default:
extensions:
Irs\BehatMagentoExtension\Extension:
magento: /path/to/magento
target: /path/to/target
store: store_code # default: empty
scope: scope_code # default: store
database:
host: test_db_host # default: localhost
user: test_db_user_name # default: root
password: test_db_password # default: empty
schema: test_db_schema
用法
要激活钩子,您需要在您特征上下文中使用 Irs\BehatMagentoExtension\Context\MagentoHooks 特性。
首次运行时,Magento 将通过 Irs\MagentoInitializer\Installer\GenericInstaller 安装到目标位置,然后默认状态将被保存到 states/default.state。在 before suite 事件中将从该状态恢复 Magento。
要在特征或场景之前恢复 Magento 到特定状态,您需要将标签 @state:state_name 添加到特征或场景(相应地)。例如,以下代码在 "Successfully describing scenario" 之前将 Magento 恢复到默认状态(已保存到 states/default.state)
Feature: Your first feature
In order to start using Behat
As a manager or developer
I need to try
@state:default
Scenario: Successfully describing scenario
Given there is something
When I do something
Then I should see something
可以使用 bin\magento save-state 命令将目标位置的当前 Magento 状态保存。
c:\>magento help save-state
Usage:
save-state [-c|--config="..."] [-p|--config-profile="..."] [-s|--name="..."]
Options:
--config (-c) Path to Behat's config (default: "behat.yml")
--config-profile (-p) Profile of Behat's config (default: "default")
--name (-s) State name (default: "states/2013-04-03-06-11-10.state")
--help (-h) Display this help message.
--quiet (-q) Do not output any message.
--verbose (-v) Increase verbosity of messages.
--version (-V) Display this application version.
--ansi Force ANSI output.
--no-ansi Disable ANSI output.
--no-interaction (-n) Do not ask any interactive question.