Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Merge branch 'develop' of github.com:Behat/Mink into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
everzet committed May 18, 2012
2 parents 97b8cfa + d4f07c7 commit 75e1925
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Behat/Mink/WebAssert.php
Expand Up @@ -89,6 +89,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.
*
Expand Down
23 changes: 23 additions & 0 deletions tests/Behat/Mink/WebAssertTest.php
Expand Up @@ -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
Expand Down

0 comments on commit 75e1925

Please sign in to comment.