dman-coders / drupal-more-extensions
Behat 的扩展 Drupal
1.0.x-dev
2018-02-20 07:01 UTC
Requires
- drupal/drupal-extension: ~3.0
This package is not auto-updated.
Last update: 2024-09-29 03:10:13 UTC
README
Behat 的扩展 Drupal
有关设置 Drupal 测试的说明,请参阅 drupal-extension 文档 https://behat-drupal-extension.readthedocs.io/
此组 '上下文' 提供了一些更多的操作集,我们可以对其进行测试。
安装
要将这些上下文包含到您的项目中
-
在您的 behat 测试项目的 composer.json 中包含此库
{ "require": { /* Other stuff */ "dman-coders/drupal-more-extensions": "~1.0@dev" }, "repositories": [ { "type": "vcs", "url": "git@github.com:jhedstrom/drupalextension.git" } ], }
并运行
composer update
。 -
在您的 behat.yml 中包含 DrupalMoreExtensions 上下文
default: suites: default: contexts: - FeatureContext - Drupal\DrupalExtension\Context\DrupalContext /* Other Stuff */ - Drupal\DrupalMoreExtensions\Context\BrowserContext - Drupal\DrupalMoreExtensions\Context\ScreenshotContext: params: path: 'screenshots' timestamped: false
您应该会看到新的命令变得可用。
功能
此处列出的操作可能不完整。运行: behat -dl
以列出实际可用的定义状态。运行 behat -di
以显示相关操作的帮助。
截图操作。
Drupal\DrupalMoreExtensions\Context\ScreenshotContext
- @Given 视口是 :arg1
- @Given 视口是 wide/medium/narrow/mobile
- @Then 我拍摄截图并保存为 :arg1
- @Then /^take a screenshot of "([^"])" and save as "([^"])"$/
和一些运行时调试添加
- @Then /^show me a screenshot$/
- @Then /^show me the HTML page$/
一些与网页交互的附加实用操作。
Drupal\DrupalMoreExtensions\Context\BrowserContext
- @Given 我等待 :arg1 秒
- 我选择垂直标签 "#edit-options"
- @Then /^I fill in ckeditor on field "([^"])" with "([^"])"$/
- @Then /^I fill in tinymce on field "([^"])" with "([^"])"$/
一些登录 Drupal 的附加实用操作
Drupal\DrupalMoreExtensions\Context\DrupalLoginContext
- @Given 我以 :arg1 登录 Drupal,密码 :arg2
- @Given 我以 :arg1 登录 OpenID,密码 :arg2
- @Given 我记住cookie
- @Given 我以用户 :name 登录
- @Given 我以 (用户) :arg1 登录 Drupal,密码 :arg2 进行身份验证
- @Given 我将管理员密码重置为 :arg1
- @Given 我以超级用户登录
安装
要包括这些新步骤和操作,
在 behat.yml 中包含
default:
suites:
default:
contexts:
- Drupal\DrupalMoreExtensions\Context\DrupalLoginContext
如果您想使用 "我作为用户 :name 登录" 操作,预先配置一些用户如下。这将不会创建这些用户,使用此来利用现有账户。
...
- Drupal\DrupalMoreExtensions\Context\DrupalLoginContext:
users:
admin:
name: admin
pass: adminpass
member:
name: "tester"
pass: "tester"