Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vjik committed Oct 27, 2024
1 parent 9f19391 commit 5ef766e
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions tests/RequestCookiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,31 @@ final class RequestCookiesTest extends TestCase
{
public function testGet(): void
{
$requestCoockie = $this->getRequestCookies();
$requestCookies = $this->createRequestCookies(['test' => 'value']);

$this->assertSame('value', $requestCoockie->get('test'));
$this->assertSame('value', $requestCookies->get('test'));
}

public function testHas(): void
{
$requestCoockie = $this->getRequestCookies();
$requestCookies = $this->createRequestCookies(['test' => 'value']);

$this->assertTrue($requestCoockie->has('test'));

$this->assertFalse($requestCoockie->has('value'));
$this->assertTrue($requestCookies->has('test'));
$this->assertFalse($requestCookies->has('non-exist'));
}

private function getRequestCookies(): RequestCookies
private function createRequestCookies(array $cookies = []): RequestCookies
{
/** @var ServerRequestInterface $serverRequestMock */
$serverRequestMock = $this->createMock(ServerRequestInterface::class);
$serverRequestMock->method('getCookieParams')->willReturn([
'test' => 'value',
]);
$serverRequestMock
->method('getCookieParams')
->willReturn($cookies);

/** @var RequestProviderInterface $requestProvider */
$requestProvider = $this->createMock(RequestProviderInterface::class);
$requestProvider->method('get')->willReturn($serverRequestMock);


return new RequestCookies($requestProvider);
}
}

0 comments on commit 5ef766e

Please sign in to comment.