stephenharris/wordpress-behat-extension
Composer 安装命令:
composer require stephenharris/wordpress-behat-extension
包简介
WordPress extension for Behat 3
关键字:
README 文档
README
This is a Behat 3.0 Extension for WordPress plugin and theme development.
The Extension allows you to use WordPress functions in your context class if you include StephenHarris\WordPressBehatExtension\Context\WordPressContext (or create and include a child class of it, i.e. make your FeatureContext ).
It also provides other contexts.
Version: 0.4.0 . This project follows SemVer.
History
This repository started off as a fork of:
- https://github.com/JohnBillion/WordPressBehatExtension
- itself a fork of https://github.com/tmf/WordPressExtension
- itself a fork of https://github.com/wdalmut/WordPressExtension
Installation
(For 'quick start' guides, please see the Recipes).
-
Add a composer development requirement for your WordPress theme or plugin:
{ "repositories": [ { "type": "vcs", "url": "https://github.com/stephenharris/WordPressBehatExtension.git" } ], "require-dev" : { "stephenharris/wordpress-behat-extension": "~0.3", "behat/mink-goutte-driver": "~1.1", "behat/mink-selenium2-driver": "~1.3.1", "johnpbloch/wordpress": "~4.6.1" } }You don't have to install WordPress via composer. But you shall need a path to a WordPress install below. Additionally you don't have to use the Goutte and Selenium2 drivers, but these are the most common.
-
Add the following Behat configuration file below. You will need:
-
The path to your WordPress install (here assumed
vendor/wordpress, relative to your project's root directory). -
The database, and database username and password of your WordPress install (here assumed
wordress_test,root,'') -
The URL of your WordPress install (In this example we'll be using php's build in server)
-
A temporary directory to store e-mails that are 'sent'
default: suites: default: contexts: - FeatureContext - \StephenHarris\WordPressBehatExtension\Context\WordPressContext - \StephenHarris\WordPressBehatExtension\Context\Plugins\WordPressPluginContext # and any other contexts you need, please see the documentation extensions: StephenHarris\WordPressBehatExtension: path: '%paths.base%/vendor/wordpress' connection: host: 'localhost' db: 'wordpress_test' username: 'root' password: '' mail: directory: '/tmp/mail' Behat\MinkExtension: base_url: 'http://localhost:8000' goutte: ~ selenium2: ~
Note the
StephenHarris\WordPressBehatExtension\Context\WordPressContextcontext included. This will cause WordPress to be loaded, and all its functions available in your context classes.. You can also include other contexts.
-
Install the vendors and initialize behat test suites
composer update # You will need to ensure a WordPress install is available, with database credentials that # mach the configuration file above vendor/bin/behat --init
-
Write some Behat features in your project's
featuresdirectory and define any steps. TheWordPressContextcontext will make all WordPress functions available in your context classes (but there is a better way).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 -
Run the tests
In our example, since we using PHP's built-in web sever, this will need to be started so that Behat can access our site.
php -S localhost:8000 -t vendor/wordpress -d disable_functions=mail
```
```bash
vendor/bin/behat
```
Documentation
Please see the Docs.
Aim
The aim of this project is to provide a collection of context classes that allow for easy testing of WordPress' core functionality. Those contexts can then be built upon to test your site/plugin/theme-specific functionality.
License
WordPressBehatExtension is open source and released under MIT license. See LICENSE file for more info.
Health Warning
This is not to be used on a live site. Your database will be cleared of all data.
Currently this extension also over-rides your wp-config.php but this implementation may change in the future.
The extension installs three mu-plugins into your install (which it assumes is at {site-path}/wp-content/mu-plugins). These plug-ins do the following:
wp-mail.php- over-rideswp_mail()function to store the e-mails locallywp-install.php- over-rideswp_install_defaults()to prevent any default content being created, with the exception of the 'Uncategorised' category.move-admin-bar-to-back.php- a workaround for #1 which prevent elements from being hidden from Selenium behind the admin menu bar.
Changelog
A changelog can be found at CHANGELOG.md.
How to help
This project needs a lot of love :). You can help by doing any of the following
- Opening an issue to request a context / step definitions
- Submitting a PR to add a context / step definition
- Submiting a PR to add to or improve the documentation
- Opening an issue you have questions or find any bugs
- Just using this extension in your development / testing workflow and providing your feedback
stephenharris/wordpress-behat-extension 适用场景与选型建议
stephenharris/wordpress-behat-extension 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 131 次下载、GitHub Stars 达 8, 最近一次更新时间为 2016 年 12 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「BDD」 「Behat」 「wordpress」 「story」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 stephenharris/wordpress-behat-extension 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 stephenharris/wordpress-behat-extension 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 stephenharris/wordpress-behat-extension 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Helper that decorates any SUS with a phpspec lazy object wrapper
Behat Context for testing Symfony Api
A Behat Extension that allows custom bootstrapping
Environment processor and contexts autoloader
Provides access to magento2 object manager from behat and allows to change magento config settings temporarly
log the behat execution into json result
统计信息
- 总下载量: 131
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 8
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-12-20