Skip to content

Commit

Permalink
merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
miya0001 committed Nov 10, 2016
2 parents 0ab7632 + 6041367 commit fafcea5
Show file tree
Hide file tree
Showing 10 changed files with 1,788 additions and 551 deletions.
37 changes: 37 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Contributing

## Automated Testing

Clone this repository.

```
$ git clone git@github.com:vccw-team/wordpress-extension.git
```

Change into the directory.

```
$ cd wordpress-extension
```

Install dependencies.

```
$ npm install
$ composer install
```

Start a WordPress server.

```
$ export WP_VERSION=latest
$ export WP_THEME=twentysixteen
$ npm run install-wp
$ npm run wp
```

Run the test!

```
$ npm test
```
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ features/
node_modules/
npm-debug.log
package.json
phpspec.yml
spec/
vendor/
wp-cli-nightly.phar
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Copyright (c) 2016 Takayuki Miyauchi <miya@wpist.me>

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
128 changes: 114 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,59 +6,159 @@
[![Latest Unstable Version](https://poser.pugx.org/vccw-team/wordpress-extension/v/unstable)](https://packagist.org/packages/vccw-team/wordpress-extension)
[![License](https://poser.pugx.org/vccw-team/wordpress-extension/license)](https://packagist.org/packages/vccw-team/wordpress-extension)

## Requires

* WordPress 4.6 or later
* PHP 5.5 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
```

Example of the `behat.yml` is following. You should edit a value of the `base_url`.
### 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
Behat\MinkExtension:
base_url: http://127.0.0.1:8080
sessions:
default:
selenium2:
wd_host: http://127.0.0.1:4444/wd/hub
```

* Add user accounts of your WordPress site to `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
```

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

## Contributing
#### Examples

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

```
Feature: I login as the specfic role
@javascript
Scenario: Login as the "administrator" role
When I login as the "administrator" role
Then I should see "Welcome to WordPress!"
```

Run to see contexts.

### Automated Testing
```
$ vendor/bin/behat --di --lang=en
```

Clone this repository.
### Install headless browser

Following is an exmaple for PhantomJS.

```
$ git clone git@github.com:vccw-team/wordpress-extension.git
$ npm install phantomjs --save
$ node_modules/.bin/phantomjs --webdriver=4444 --ignore-ssl-errors=yes --cookies-file=/tmp/webdriver_cookie.txt
```

Change into the directory.
### Run tests

```
$ cd wordpress-extension
$ vendor/bin/behat
```

Install dependencies.
### Running tests as npm-scripts

Following is an example to run phantomjs and tests automatically.

Save following as `bin/run-tests.js`.

```
$ npm install
$ composer install
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 );
} )
} )
```

Start a WordPress site.
Add it to `package.json`.

```
$ npm run install-wp
$ npm run wp
{
"scripts": {
"test": "/usr/bin/env node bin/run-tests.js"
},
}
```

Run the test!
Then just run:

```
$ npm test
Expand Down
22 changes: 11 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
{
"name": "vccw-team/wordpress-extension",
"description": "WordPress extension for the Behat",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Takayuki Miyauchi",
"email": "miya0001@users.noreply.github.com"
}
],
"minimum-stability": "dev",
"require": {
"behat/behat": "3.*@stable",
"behat/mink": "1.6.*@dev",
"behat/mink-extension": "2.*@dev",
"behat/mink-browserkit-driver": "*@dev",
"behat/mink-goutte-driver": "*@dev",
"behat/mink-selenium2-driver": "*@dev"
"behat/behat": "~3.2",
"behat/mink": "~1.7",
"behat/mink-extension": "~2.2",
"behat/mink-selenium2-driver": "~1.3.1",
"phpunit/phpunit": "^5.6"
},
"require-dev": {
"phpspec/phpspec": "^3.1"
},
"autoload": {
"psr-4": {
"VCCW\\Behat\\Mink\\WordPressExtension\\": "src/"
}
"psr-4": {
"VCCW\\Behat\\Mink\\WordPressExtension\\": "src/"
}
}
}
Loading

0 comments on commit fafcea5

Please sign in to comment.