Hello to all,
Recently we upgraded behatch contexts from 2.5 version to 2.8.1 with several upgrade and i encounter a problem with my API's tests.
So basically i send a request to a page that connect an user then
Scenario: Simple scenario that
Given I am connected as user
When I send a "GET" request to "/rest/user"
Then the response status code should be 200
When I send a "GET" request to "/rest/user"
Then the response status code should be 200
Before the update this code use to work, after it the last context return this message :
Current response status code is 403, but 200 expected. (Behat\Mink\Exception\ExpectationException)
The function related to the context I am connected as user extends RawMinkContext and simply set a session ID in cookies.
public function iAmConnectedAs($login)
{
$loginUrl = $this->locatePath('/login.php');
$this->getSession()->setCookie('PHPSESSID', uniqid());
$this->request('POST', $loginUrl, ['login' => $login, 'passwd' => $login]);
}
During a debug session i saw that Cookies are emptied between sessions. So that explains the 403 response but why cookies are emptied? Did anyone encountered this after an update? Let me know if i have something to add.
I also write a question on StackOverflow