Skip to content

Commit 42b001d

Browse files
committed
v1.2.2
2 parents ee658ce + 0e6617f commit 42b001d

File tree

6 files changed

+21
-47
lines changed

6 files changed

+21
-47
lines changed

README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,24 @@ default:
4949
administrator:
5050
username: admin
5151
password: admin
52+
editor:
53+
username: editor
54+
password: editor
5255
Behat\MinkExtension:
5356
base_url: http://127.0.0.1:8080
57+
default_session: default
5458
sessions:
5559
default:
5660
selenium2:
5761
wd_host: http://127.0.0.1:4444/wd/hub
62+
goutte:
63+
goutte: ~
64+
5865
```
5966

60-
* Add user accounts of your WordPress site to `VCCW\Behat\Mink\WordPressExtension > roles`.
67+
* Add user accounts of your WordPress site into `VCCW\Behat\Mink\WordPressExtension > roles`.
6168
* Update value of the `Behat\MinkExtension > base_url` to your hostname.
62-
63-
#### You can add multiple user like following.
69+
* You can add multiple user like following.
6470

6571
```
6672
extensions:
@@ -74,6 +80,7 @@ default:
7480
password: editor
7581
```
7682

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

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

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

105113
```
106114
Feature: HTTP response

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
"behat/mink-extension": "~2.2",
1515
"behat/mink-selenium2-driver": "~1.3.1",
1616
"phpunit/phpunit": "^5.6",
17-
"guzzlehttp/guzzle": "^6.2",
1817
"behat/mink-goutte-driver": "^1.2"
1918
},
2019
"require-dev": {

composer.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

features/http-response.feature

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/Context/RawWordPressContext.php

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,6 @@ class RawWordPressContext extends RawMinkContext
1212
protected $timeout = 60;
1313
private $parameters; // parameters from the `behat.yml`.
1414
private $variables = array();
15-
private $guzzle;
16-
private $guzzle_params = array(
17-
'exceptions' => false,
18-
'verify' => false,
19-
);
20-
21-
public function __construct()
22-
{
23-
$this->guzzle = new \GuzzleHttp\Client();
24-
}
2515

2616
/**
2717
* Set parameter form initializer
@@ -95,16 +85,12 @@ protected function get_http_headers()
9585
* Get contents from $url.
9686
*
9787
* @param string $url The URL.
98-
* @param string $method The request method.
99-
* @param array $params An array of the http request.
10088
* @return string The contents.
10189
*/
102-
protected function get_contents( $url, $method = 'GET', $params = array() )
90+
protected function get_contents( $url )
10391
{
104-
$params = $params + $this->guzzle_params;
105-
$response = $this->guzzle->request( $method, $url, $params );
106-
107-
return $response->getBody();
92+
$this->getSession()->visit( $url );
93+
return $this->getSession()->getPage()->getText();
10894
}
10995

11096
/**
@@ -299,7 +285,8 @@ protected function get_current_theme()
299285
$page = $this->getSession()->getPage();
300286
$e = $page->find( 'css', ".theme.active" );
301287
if ( $e ) {
302-
$theme = $e->getAttribute( "data-slug" );
288+
$classes = preg_split( "/\s+/", trim( $e->getAttribute( "aria-describedby" ) ) );
289+
$theme = preg_replace( "/\-(name|action)$/", "", $classes[0] );
303290
if ( $theme ) {
304291
return $theme;
305292
}
@@ -352,7 +339,7 @@ public function replace_variables( $str )
352339
* @param none
353340
* @return string Admin url like `/wp-admin`
354341
*/
355-
protected function get_admin_url()
342+
public function get_admin_url()
356343
{
357344
$params = $this->get_params();
358345
return $params['admin_url'];

src/Context/WordPressContext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function save_env_as_var( $env, $var )
2525

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

0 commit comments

Comments
 (0)