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

Add automatic soft isolation to Session docs #52

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
20 changes: 13 additions & 7 deletions guides/session.rst
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,10 @@ Resetting the Session
---------------------

The primary aim for Mink is to provide a single consistent web browsing API
for acceptance tests. But a very important part in testing is isolation.
for acceptance tests. But a very important part in testing is isolation.
Copy link
Member

Choose a reason for hiding this comment

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

Please don't add trailing whitespaces

Copy link
Member

Choose a reason for hiding this comment

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

Better yet enable automatic trailing space removal in your editor.


Mink provides two very useful methods to isolate tests, which can be used
in your test's ``teardown`` methods:
So Mink provides two very useful methods to isolate tests, which can be used
in your tests' ``teardown`` methods:

.. code-block:: php

Expand All @@ -204,10 +204,16 @@ need to start the session before any other action. The ``Session::restart``
shortcut allows you to do these 2 steps in a single call.

The drawback of closing the browser and starting it again is that it takes
time. In many cases, a lower level of isolation is enough in favor of a faster
resetting. The ``Session::reset`` method covers this use case. It will try
to clear the cookies and reset the request headers and the browser history
to the limit of the driver possibilities.
time. In many cases, a shallower level of isolation is enough in favor of a
faster resetting. The ``Session::reset`` method covers this use case. It
will try to clear the cookies, reset the request headers and clear the
browser history - though there are some driver limitations that mean this
isn't always effective. For example:

* Selenium will not allow cookies to be cleared from anything other than
the current domain. So a test that runs across different domains (for
example your site and PayPal's sandbox) cannot be properly isolated using
``Session::reset()``.

Taking all this into account, it is recommended to use ``Session::reset()``
by default and to call ``Session::stop()`` when you need really full isolation.
Expand Down