Skip to content

Commit

Permalink
v1.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
miya0001 committed Dec 25, 2016
2 parents ee658ce + 0e6617f commit 42b001d
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 47 deletions.
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,24 @@ default:
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 to `VCCW\Behat\Mink\WordPressExtension > roles`.
* 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.
* You can add multiple user like following.

```
extensions:
Expand All @@ -74,6 +80,7 @@ default:
password: editor
```

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

### Write features
Expand All @@ -100,7 +107,8 @@ Feature: I login as the specfic role
```

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

```
Feature: HTTP response
Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"behat/mink-extension": "~2.2",
"behat/mink-selenium2-driver": "~1.3.1",
"phpunit/phpunit": "^5.6",
"guzzlehttp/guzzle": "^6.2",
"behat/mink-goutte-driver": "^1.2"
},
"require-dev": {
Expand Down
4 changes: 2 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 0 additions & 20 deletions features/http-response.feature

This file was deleted.

25 changes: 6 additions & 19 deletions src/Context/RawWordPressContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,6 @@ class RawWordPressContext extends RawMinkContext
protected $timeout = 60;
private $parameters; // parameters from the `behat.yml`.
private $variables = array();
private $guzzle;
private $guzzle_params = array(
'exceptions' => false,
'verify' => false,
);

public function __construct()
{
$this->guzzle = new \GuzzleHttp\Client();
}

/**
* Set parameter form initializer
Expand Down Expand Up @@ -95,16 +85,12 @@ protected function get_http_headers()
* Get contents from $url.
*
* @param string $url The URL.
* @param string $method The request method.
* @param array $params An array of the http request.
* @return string The contents.
*/
protected function get_contents( $url, $method = 'GET', $params = array() )
protected function get_contents( $url )
{
$params = $params + $this->guzzle_params;
$response = $this->guzzle->request( $method, $url, $params );

return $response->getBody();
$this->getSession()->visit( $url );
return $this->getSession()->getPage()->getText();
}

/**
Expand Down Expand Up @@ -299,7 +285,8 @@ protected function get_current_theme()
$page = $this->getSession()->getPage();
$e = $page->find( 'css', ".theme.active" );
if ( $e ) {
$theme = $e->getAttribute( "data-slug" );
$classes = preg_split( "/\s+/", trim( $e->getAttribute( "aria-describedby" ) ) );
$theme = preg_replace( "/\-(name|action)$/", "", $classes[0] );
if ( $theme ) {
return $theme;
}
Expand Down Expand Up @@ -352,7 +339,7 @@ public function replace_variables( $str )
* @param none
* @return string Admin url like `/wp-admin`
*/
protected function get_admin_url()
public function get_admin_url()
{
$params = $this->get_params();
return $params['admin_url'];
Expand Down
2 changes: 1 addition & 1 deletion src/Context/WordPressContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function save_env_as_var( $env, $var )

/**
* Check http status code.
* Example: Given save env $WP_VERSION as {WP_VERSION}
* Example: the HTTP status should be 400
*
* @param string $expect The HTTP status code.
* @then /^the HTTP status should be (?P<expect>[0-9]+)$/
Expand Down

0 comments on commit 42b001d

Please sign in to comment.