johnbillion / wordpress-behat-extension
0.1.5
2017-05-27 12:01 UTC
Requires
- behat/behat: ~3.0,>=3.0.4
- behat/mink-extension: ~2.0@dev
- symfony/filesystem: ~2.3
- symfony/finder: ~2.3
This package is auto-updated.
Last update: 2022-02-01 12:46:32 UTC
README
这是一个为WordPress插件和主题开发而设计的Behat 3.0扩展。您可以使用它来测试您的WordPress安装,或者仅测试您的插件/主题,而无需在正常的WordPress安装中安装它们(即独立安装)。此扩展允许您在上下文类中使用WordPress函数(如果您从Johnbillion\WordPressExtension\Context\WordPressContext扩展它)。
安装
-
为您的WordPress主题或插件添加composer开发依赖项
{ "require-dev" : { "johnbillion/wordpress-behat-extension": "~0.1", "johnpbloch/wordpress": "~4.0.0" } }
-
添加以下Behat配置文件
default: suites: default: contexts: - Johnbillion\WordPressExtension\Context\WordPressContext extensions: Johnbillion\WordPressExtension: path: '%paths.base/vendor/wordpress' Behat\MinkExtension: base_url: 'http://localhost:8000' sessions: default: goutte: ~
-
安装供应商并初始化behat测试套件
composer update vendor/bin/behat --init
-
启动您的开发Web服务器,并将其文档根指向供应商中的wordpress目录(无邮件功能)
php -S localhost:8000 -t vendor/wordpress -d disable_functions=mail
-
编写一些Behat特性并测试它们
Feature: Manage plugins In order to manage plugins As an admin I need to enable and disable plugins Background: Given I have a vanilla wordpress installation | name | email | username | password | | BDD WordPress | your@email.com | admin | test | And I am logged in as "admin" with password "test" Scenario: Enable the dolly plugin Given there are plugins | plugin | status | | hello.php | enabled | When I go to "/wp-admin/" Then I should see a "#dolly" element Scenario: Disable the dolly plugin Given there are plugins | plugin | status | | hello.php | disabled | When I go to "/wp-admin/" Then I should not see a "#dolly" element
-
运行测试
vendor/bin/behat