Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'develop' of github.com:Behat/Mink into develop

  • Loading branch information...
commit 75e1925754abb766a669699fa6ae8b0a1211c024 2 parents 97b8cfa + d4f07c7
Konstantin Kudryashov everzet authored
Showing with 38 additions and 0 deletions.
  1. +15 −0 src/Behat/Mink/WebAssert.php
  2. +23 −0 tests/Behat/Mink/WebAssertTest.php
15 src/Behat/Mink/WebAssert.php
View
@@ -90,6 +90,21 @@ public function addressMatches($regex)
}
/**
+ * Checks that specified cookie exists
+ *
+ * @param string $name cookie name
+ *
+ * @throws Behat\Mink\Exception\ExpectationException
+ */
+ public function cookieExists($name)
+ {
+ if ($this->session->getCookie($name) === null) {
+ $message = sprintf('Cookie "%s" is not set, but should be.', $name);
+ throw new ExpectationException($message, $this->session);
+ }
+ }
+
+ /**
* Checks that current response code equals to provided one.
*
* @param integer $code
23 tests/Behat/Mink/WebAssertTest.php
View
@@ -74,6 +74,29 @@ public function testAddressMatches()
);
}
+ /**
+ * @covers Behat\Mink\WebAssert::cookieExists
+ */
+ public function testCookieExists()
+ {
+ $this->session->
+ expects($this->any())->
+ method('getCookie')->
+ will($this->returnValueMap(
+ array(
+ array('foo', '1'),
+ array('bar', null),
+ )
+ ));
+
+ $this->assertCorrectAssertion('cookieExists', array('foo'));
+ $this->assertWrongAssertion(
+ 'cookieExists', array('bar'),
+ 'Behat\Mink\Exception\ExpectationException',
+ 'Cookie "bar" is not set, but should be.'
+ );
+ }
+
public function testStatusCodeEquals()
{
$this->session
Please sign in to comment.
Something went wrong with that request. Please try again.