vccw-team/wordpress-extension 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

vccw-team/wordpress-extension

Composer 安装命令:

composer require vccw-team/wordpress-extension

包简介

WordPress extension for the Behat

README 文档

README

Build Status Latest Stable Version Total Downloads Latest Unstable Version License

Requires

  • WordPress 4.6 or later
  • PHP 5.6 or later

Getting Started

Install dependencies

The recomended way to install is by using Composer.

$ composer require vccw-team/wordpress-extension:@stable

Initialize Behat

After that you will be able to initialize the project.

$ vendor/bin/behat --init

Configuration

Place the behat.yml like following.

default:
  suites:
    default:
      paths:
        - %paths.base%/features
      contexts:
        - FeatureContext
        - VCCW\Behat\Mink\WordPressExtension\Context\WordPressContext
        - Behat\MinkExtension\Context\MinkContext
  extensions:
    VCCW\Behat\Mink\WordPressExtension:
      roles:
        administrator:
          username: admin
          password: admin
        editor:
          username: editor
          password: editor
    Behat\MinkExtension:
      base_url: http://127.0.0.1:8080
      default_session: default
      sessions:
        default:
          selenium2:
            wd_host: http://127.0.0.1:4444/wd/hub
        goutte:
          goutte: ~

  • Add user accounts of your WordPress site into VCCW\Behat\Mink\WordPressExtension > roles.
  • Update value of the Behat\MinkExtension > base_url to your hostname.
  • You can add multiple user like following.
  extensions:
    VCCW\Behat\Mink\WordPressExtension:
      roles:
        administrator:
          username: admin
          password: admin
        editor:
          username: editor
          password: editor

See: https://github.com/vccw-team/wordpress-extension/blob/master/behat.yml.dist

Write features

You can write features with Gherkin language.

https://github.com/cucumber/cucumber/wiki/Gherkin

Example *.feature are in the following.

https://github.com/vccw-team/wordpress-extension/tree/master/features

Examples

Login as the administrator role and I should see "Dashboard".

Feature: I login as the specfic role

  Scenario: Login as the "administrator" role

    When I login as the "administrator" role
    Then I should see "Welcome to WordPress!"

Selenium2 driver can't retrieve the HTTP response. So you have to use @mink::goutte tag like following in your *.feature. But goutte driver can't exec JavaScript.

Feature: HTTP response

  @mink:goutte
  Scenario: Check http status code

    When I am on "/"
    Then the HTTP status should be 200

    When I am on "/the-page-not-found"
    Then the HTTP status should be 404

Run to see contexts.

$ vendor/bin/behat -di --lang=en

Install headless browser

Following is an exmaple for PhantomJS.

$ npm install phantomjs-prebuilt --save
$ node_modules/.bin/phantomjs --webdriver=4444 --ignore-ssl-errors=yes --cookies-file=/tmp/webdriver_cookie.txt

Run tests

$ vendor/bin/behat

Running tests as npm-scripts

Following is an example to run phantomjs and tests automatically.

Save following as bin/run-tests.js.

const phantomjs = require( 'phantomjs-prebuilt' )
const spawn = require( 'child_process' ).spawn

const argv = process.argv
argv.shift()
argv.shift()

phantomjs.run(
  '--webdriver=4444',
  '--ignore-ssl-errors=yes',
  '--cookies-file=/tmp/webdriver_cookie.txt'
).then( program => {
  const behat = spawn( 'vendor/bin/behat', argv, { stdio: "inherit" } )
  behat.on( 'exit', ( code ) => {
    program.kill()
    process.exit( code );
  } )
} )

Add it to package.json.

{
  "scripts": {
    "test": "/usr/bin/env node bin/run-tests.js"
  },
}

Then just run:

$ npm test

统计信息

  • 总下载量: 339
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 12
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 12
  • Watchers: 2
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-10-31

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固