Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
[6.x] Add methods for sending cookies with test requests #30101
This introduces methods for making it easier to send cookies in HTTP Tests. Previously, sending cookies restricted developers to using the low-level
$cookies = [ 'name1' => encrypt('value1'), 'name2' => encrypt('value2') ]; $response = $this->call('get', 'test', , $cookies);
$response = $this->withCookies([ 'name1' => 'value1', 'name2' => 'value2' ])->get('test');
Similar to the header methods, the following methods were added:
Cookies are prepared before sending the HTTP request and encrypted using the
This implementation implies a few design decisions:
In the end, these methods improve the out-of-the-box developer experience by making it easier to test requests using cookies. For more complex scenarios, developers can continue using
These tests are pretty weak and could likely be removed. They only verify internal properties. My attempts to test sending the actual cookies required mocking out parts of this internal trait which was not pretty.
If there is some kind of echo or loopback test request I can make let me know and I will gladly add more tests.