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

Mink extension additions #23

Merged
merged 3 commits into from
Nov 4, 2015
Merged
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
14 changes: 14 additions & 0 deletions knpu/login-scenario.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,20 @@ this *is* ugly - I have another debugging tip later. There are two important thi
we're still on the login page for some reason. And second, if you scan down, you'll see
the error message: "invalid credentials".

***tip
You can also *see* the failed page by using `Then show last response`:

[[[ code('2cae1ecf50') ]]]

You'll just need to configure the `show_cmd` in `behat.yml`. On OSX, I use `show %s`,
but using `firefox %s` is common on other systems:

[[[ code('5f7179f0b0') ]]]

You can even set the `show_auto` setting to `true` to automatically open a browser
on failures.
***

Let's remove our debug line and update this to the correct password which is
"admin". And now let's rerun it! It's alive!

Expand Down
17 changes: 17 additions & 0 deletions knpu/mink-inside-feature-context.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,20 @@ Now we can shorten both definition functions a bit with `$this->getPage()`:
Test the final scenarios out. Perfect! Now we have access to Mink inside of
`FeatureContext` *and* we know that including CSS inside of scenarios is
not the best way to make friends.

## The assertSession

One more quick shortcut. Thanks to the `RawMinkContext` base class, we also have
access to a cool object called `WebAssert` through the `assertSession()` method.
Replace `getPage()` with `assertSession()` and `find()` with `elementExists()`. Now,
remove the `assertNotNull()` call:

[[[ code('00e143c7c9') ]]]

The `elementExists` *finds* the element *and* asserts that it exists all at once.
Nice! Make the same changes for pressing the button:

[[[ code('325d5d01d1') ]]]

The [WebAssert](https://github.com/minkphp/Mink/blob/master/src/WebAssert.php) class
has a bunch of other handy methods on it - check them out:
Copy link

Choose a reason for hiding this comment

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

: looks weird here as it is the end of the chapter

Copy link
Member Author

Choose a reason for hiding this comment

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

you're right - I must have been thinking I was going to add a code-block below. I'll go change that