Skip to content
This repository was archived by the owner on Apr 20, 2021. It is now read-only.
This repository was archived by the owner on Apr 20, 2021. It is now read-only.

Cookies are emptied between requests.  #271

@brice

Description

@brice

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions