-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added lots of stuff for v1.5
- Loading branch information
Showing
68 changed files
with
3,148 additions
and
2,069 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# AbstractApiContext | ||
This context has no steps by itself, but helper to mock away external APIs in tests and check if they are called correctly, or how the app behaves with different responses. | ||
For example if you want to test your connection to an API for users | ||
|
||
## Given | ||
### `Given a call to the user api <url> will return` | ||
``` | ||
""" | ||
{"some":"json response"} | ||
""" | ||
``` | ||
or | ||
``` | ||
""" | ||
HTTP/1.0 OK | ||
Content-Type: application/json | ||
{"some":"json response with http headers"} | ||
""" | ||
``` | ||
Will mock the response, the next request to his api will get. | ||
Backed by using the `addResponse` method. | ||
|
||
## Then | ||
### `the user api <url> has been called` | ||
Check if the api call was performed right, by the application. | ||
Can also contain payload or methods. | ||
Backed by using the `assertApiCall` method. | ||
### `the user api <url> has not been called` | ||
The opposite, by using `assertNoApiCall` method. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# AbstractDatabaseContext | ||
This context has no steps by itself, but helper to create an own context by extending it. | ||
For example if you want to create users and assign them to groups this could look like. | ||
|
||
## Given | ||
### `Given there is a user` | ||
``` | ||
| firstname | Test | | ||
| lastname | User | | ||
``` | ||
Create the entity by mapping attributes from the table. | ||
Uses `createObject` under the hood. | ||
### `Given the user <userId> is assigned to group <groupId>` | ||
Create a relation between two entities. Uses `createRelation` under the hood. | ||
|
||
## Then | ||
**NOTE:** You need to name the `Thens` a bit differently from the `Givens`, as behat will not distinguish the keywords. | ||
Otherwise, you would create objects/relations instead of checking if they exist. | ||
Usually we do this by adding things like "*exists*" or "*now*". | ||
|
||
### `Then there exists a user` | ||
``` | ||
| firstname | Test | | ||
| lastname | User | | ||
``` | ||
Check if the entity with the given attributes can be found. | ||
### `Then there exists no user` | ||
The opposite. | ||
### `Then user<userId> is now assigned to group <groupId>` | ||
Check if the relation exists. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# CommandContext | ||
This context contains steps to test symfony commands | ||
|
||
## When | ||
### `When I run command <command>` | ||
Execute the given symfony command, including parsing of arguments. | ||
|
||
## Then | ||
### `Then the command has a return value of <code>` | ||
Check the return code. 0 indicates a success, everything else an error. | ||
### `Then the command outputs <text>` | ||
Check if the text is contained somewhere in the command's output. | ||
### `Then the command does not output <text>` | ||
Make sure, that the given text is not in the command's output. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# DateContext | ||
This context manipulates the time. It uses the uopz extension and [ClockMock](https://packagist.org/packages/slope-it/clock-mock). | ||
|
||
## Given | ||
### `Given the current date is <date>` | ||
Modify the date, that is returned by `date()` or `new DateTime()`. | ||
Will automatically be reset to the current date before each scenario. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# FormContext | ||
Although it's technically and logically close to the HtmlContext, the form thing have an extra context. | ||
This is because of the high complexity and huge amount of steps it contains. | ||
|
||
## When | ||
### `When I use form <name>` | ||
Bind all following steps to this named form. | ||
### `When I fill <value> into <fieldName>` | ||
Fill an input field. | ||
### `When I select <fieldName> radio button with value <value>` | ||
Select a radio button. | ||
### `When I clear field <fieldName>` | ||
Reset the value of an input field. | ||
### `When I check <fieldName> checkbox` | ||
Check a single checkbox | ||
### `When I check <fieldName> checkbox with value <value>` | ||
Check an array checkbox | ||
### `When I uncheck <fieldName> checkbox` | ||
Uncheck a single checkbox. | ||
### `When I uncheck <fieldName> checkbox with value <value>` | ||
Uncheck an array checkbox | ||
### `When I select <value> from <fieldName>` | ||
Select from a dropdown. | ||
### `When I select <fixture> upload at <fieldName>` | ||
Select a file upload. | ||
### `When I add an input field <fieldName>` | ||
Add a new field to the form. | ||
### `When I remove an input field <fieldName>` | ||
Remove a field from the form. | ||
### `When I remove a select field <fieldName>` | ||
Remove a dropdown from the form. | ||
### `When I submit the form` | ||
Submit the form without a button. | ||
### `When I submit the form with button <buttonName>` | ||
Submit the form with a specific button. | ||
|
||
## Then | ||
### `Then the page contains a form named <name>` | ||
Check existence of the form. | ||
### `Then the form contains an input field` | ||
Check existence of the field (and it's attributes). | ||
### `Then the form contains a select` | ||
Check existence of the dropdown. | ||
### `Then select <fieldName> contains option <label>` | ||
Check existence of a dropdown option. | ||
### `Then select <fieldName> does not contain option` | ||
Check absence of a dropdown option. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# HtmlContext | ||
Performs checks on the plain response or DOM. | ||
|
||
## When | ||
### `When I remove attribute <attr> from <xpath>` | ||
Modify the DOM to remove attributes like "disabled". | ||
|
||
## Then | ||
### `Then I see <text>` | ||
Check if the string is contained somewhere in the plain text response. | ||
### `Then I don't see <text>` | ||
Check if the string is not contained somewhere in the plain text response. | ||
### `Then I see :text1 before :text2` | ||
Check if the string comes before the other string. Useful to test sorting. | ||
### `Then I see a(n) :tag tag <text>` | ||
Check for a specific html tag. Attributes can be defined in a table. Text is optional and matched against the strip_tags content. | ||
### `Then I don\'t see a(n) :tag tag :content` | ||
The opposite. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# HttpContext | ||
Performs HTTP Operations (Request/Response). | ||
|
||
## When | ||
### `When I visit <url>` | ||
Open a page. | ||
### `When I navigate to <url> with http headers` | ||
Open a page but add some headers (from table) in the request. | ||
### `When I make a <method> request to <url>` | ||
Perform a request with a different method and optional json data. | ||
### `When I follow the redirect` | ||
Visit the page that is set in the location header of the previous response. | ||
|
||
## Then | ||
### `Then the response status code is <code>` | ||
Check the HTTP Status code. | ||
### `Then the page shows up` | ||
Alias for status code 200. | ||
### `Then the response has http headers` | ||
Check for the existence of certain HTTP Headers. | ||
### `Then I am being redirected to <url>` | ||
Check if the status code and location header are set. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# JsonContext | ||
HTTP Operations with json payload in request/response. | ||
|
||
## When | ||
### `When I make a :method request with json data to :url` | ||
Perform a request with json payload | ||
|
||
## Then | ||
### `Then the response json matches` | ||
Check if the JSON response is equivalent to the given json (ignores formatting). | ||
### `Then the response json contains` | ||
Check if the given JSON is contained in the response (ignoring extra keys). | ||
### `Then the response json does not contain` | ||
Check that the response does not contain the given object. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# LoggingContext | ||
Checks if logging works as expected. | ||
Uses a MockLogger under the hood. | ||
Is independent of monolog as it's using the PSR Logger. | ||
|
||
## Then | ||
### `Then the log contains a(n) <level> entry <text>` | ||
Check if the given message wit the given severity exists. | ||
Can optionally also check for the logging context via table. |
Oops, something went wrong.