Skip to content

Commit

Permalink
Recycle code in cookieExistsWithValue
Browse files Browse the repository at this point in the history
  • Loading branch information
omarlopesino committed Jul 22, 2024
1 parent b2cb56b commit 6864118
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/Behat/Context/CookieComplianceContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -370,11 +370,8 @@ public function cookieExists($cookie_name) {
* @Given the cookie with name :cookie_name exists with value :value
*/
public function cookieExistsWithValue($cookie_name, $value) {
$cookie_value = $this->getSession()->getDriver()->getCookie($cookie_name);
if (empty($cookie_value)) {
throw new \Exception(sprintf("Cookie with name %s does not have value.", $cookie_name));
}
if (!empty($value) && $value != $cookie_value) {
$this->cookieExists($cookie_name);
if ($this->getSession()->getDriver()->getCookie($cookie_name) != $cookie_value) {
throw new \Exception(sprintf("Cookie with name %s does not have the expected value %s, it has %s.", $cookie_name, $value, $cookie_value));
}
}
Expand Down

0 comments on commit 6864118

Please sign in to comment.