Skip to content

Commit

Permalink
tests: add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kamarton committed Aug 27, 2024
1 parent c0328fb commit 29474f4
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tests/Matchers/MatcherHeaderAbstractTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace SmartonDev\HttpCache\Tests\Matchers;

use PHPUnit\Framework\TestCase;
use SmartonDev\HttpCache\Tests\Matchers\Mocks\MatcherHeaderAbstractMock;

class MatcherHeaderAbstractTest extends TestCase
{
public function testHeaders(): void
{
$matcher = new MatcherHeaderAbstractMock();
$matcher->headers(['header' => 'value']);
$this->assertSame(['header' => 'value'], $matcher->getHeaders());
}

public function testWithHeaders(): void
{
$matcher = new MatcherHeaderAbstractMock();
$matcher2 = $matcher->withHeaders(['header' => 'value']);
$this->assertSame([], $matcher->getHeaders());
$this->assertSame(['header' => 'value'], $matcher2->getHeaders());
}

public function testResetHeaders(): void
{
$matcher = new MatcherHeaderAbstractMock();
$matcher->headers(['header' => 'value']);
$matcher->resetHeaders();
$this->assertSame([], $matcher->getHeaders());
}

public function testWithoutHeaders(): void
{
$matcher = new MatcherHeaderAbstractMock();
$matcher->headers(['header' => 'value']);
$matcher2 = $matcher->withoutHeaders();
$this->assertSame(['header' => 'value'], $matcher->getHeaders());
$this->assertSame([], $matcher2->getHeaders());
}
}
13 changes: 13 additions & 0 deletions tests/Matchers/Mocks/MatcherHeaderAbstractMock.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace SmartonDev\HttpCache\Tests\Matchers\Mocks;

use SmartonDev\HttpCache\Matchers\MatcherHeaderAbstract;

class MatcherHeaderAbstractMock extends MatcherHeaderAbstract
{
public function getHeaders() : array
{
return $this->headers;
}
}

0 comments on commit 29474f4

Please sign in to comment.