Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvments #9

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions features/context.feature
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ Feature: client aware context
public function theClientShouldBeSet() {
PHPUnit_Framework_Assert::assertInstanceOf('GuzzleHttp\Client', $this->client);
}

/**
* @Then the client default option :option should be equal to true
*/
public function theClientDefaultOptionShouldBeEqualToTrue($option) {
PHPUnit_Framework_Assert::assertSame(true, $this->client->getDefaultOption($option));
}
}
"""

Expand All @@ -34,7 +41,9 @@ Feature: client aware context
"""
default:
extensions:
Behat\WebApiExtension: ~
Behat\WebApiExtension:
defaults:
debug: true
"""
And a file named "features/client.feature" with:
"""
Expand All @@ -45,12 +54,13 @@ Feature: client aware context

Scenario: client is set
Then the client should be set
And the client default option "debug" should be equal to true
"""
When I run "behat -f progress features/client.feature"
Then it should pass with:
"""
When I run "behat -f progress features/client.feature"
Then it should pass with:
"""
.
..

1 scenario (1 passed)
1 step (1 passed)
"""
1 scenario (1 passed)
2 steps (2 passed)
"""
96 changes: 96 additions & 0 deletions features/testapp.feature
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,19 @@ Feature: Test app verification
"pass": "pass"
}
'''

Scenario:
When I send a POST request to "echo" with form data:
| name | name |
| pass | pass |
Then the response should contain "POST"
And the response should contain json:
'''
{
"name" : "name",
"pass": "pass"
}
'''
"""
When I run "behat features/send_form.feature"
Then it should pass with:
Expand Down Expand Up @@ -204,6 +217,58 @@ Feature: Test app verification
1 scenario (1 passed)
"""

Scenario: Asserting on the headers
Given a file named "features/assert_headers.feature" with:
"""
Feature: Exercise WebApiContext Assert Header
In order to validate the assert_header step
As a context developer
I need to be able to assert on the content of response headers

Scenario:
When I send a GET request to "echo"
Then the response header "Content-Type" should be equal to "application/json"
Then the response header "Content-Type" should contain "json"
Then the response header "Content-Type" should not contain "magic"
Then the response header "Content-Type" should not be equal to "application"
"""
When I run "behat features/assert_headers.feature"
Then it should pass with:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this step (and other steps where command output is not inportant) could be simplified:

Then it should pass

I think there is no need to test progress formatter.

"""
.....

1 scenario (1 passed)
"""

Scenario: Asserting on the body
Given a file named "features/assert_body.feature" with:
"""
Feature: Exercise WebApiContext Assert Body
In order to validate the assert body steps
As a context developer
I need to be able to assert on the content of the body

Scenario:
When I send a GET request to "hello/Adrien"
Then the response should contain "Adrien"
And the response should not contain "foobar"
And the response should be equal to:
'''
Hello Adrien
'''
And the response should not be equal to:
'''
Hello
'''
"""
When I run "behat features/assert_body.feature"
Then it should pass with:
"""
.....

1 scenario (1 passed)
"""

Scenario: Authentication
Given a file named "features/authentication.feature" with:
"""
Expand All @@ -227,3 +292,34 @@ Feature: Test app verification

1 scenario (1 passed)
"""

Scenario: Redirects
Given a file named "features/redirects.feature" with:
"""
Feature: Exercise WebApiContext Redirects checking
In order to validate the redirect steps
As a context developer
I need to be able to detect and assert on redirects

Scenario:
When I send a GET request to "redirect" with query parameters:
| url | /hello/christophe |
Then I should be redirected
Then I should be redirected to "/hello/christophe"

Scenario:
Given I do not follow redirects
When I send a GET request to "redirect" with query parameters:
| url | /hello/christophe |
Then the response code should be 302
And the response header "Location" should be equal to "/hello/christophe"
And I should be redirected
Then I should be redirected to "/hello/christophe"
"""
When I run "behat features/redirects.feature"
Then it should pass with:
"""
.........

2 scenarios (2 passed)
"""
Loading