Skip to content

Commit

Permalink
Merge pull request #28 from utopia-php/feat-add-cookie-test
Browse files Browse the repository at this point in the history
  • Loading branch information
lohanidamodar authored Jul 26, 2023
2 parents 5b60e7f + a7ce4c4 commit dc93f11
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/e2e/Swoole/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ public function testCanRespondWithChunck(): void
$this->assertEquals('Hello World!', $response['body']);
}

public function testResponseWithCookie(): void
{
$response = $this->client->call(Client::METHOD_GET, '/cookie');
$this->assertNotEmpty($response['headers']['set-cookie']);
$this->assertEquals('Hello with cookie!', $response['body']);
}

public function testCanRespondWithRedirect(): void
{
$response = $this->client->call(Client::METHOD_GET, '/redirect');
Expand Down
7 changes: 7 additions & 0 deletions tests/e2e/server.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@
$response->send($request->getProtocol());
});

App::get('/cookie')
->inject('response')
->action(function (Response $response) {
$response->addCookie('new-cookie', 'session-secret', \time(), '/', 'domain.com', true, true, null);
$response->send('Hello with cookie!');
});

$http->on('request', function (SwooleRequest $swooleRequest, SwooleResponse $swooleResponse) {
$request = new Request($swooleRequest);
$response = new Response($swooleResponse);
Expand Down

0 comments on commit dc93f11

Please sign in to comment.