diff --git a/CHANGELOG.md b/CHANGELOG.md index f8ab4ac7..6d334dd6 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased ### Changed - Hotfix. +### Added +- Add assertions to test identical headers in HEAD and GET requests automatically. ## 0.0.25 - 2023-08-31 ### Changed diff --git a/tests/FeatureTests/BaseRequestTestCase.php b/tests/FeatureTests/BaseRequestTestCase.php index 4c092e0e..b9f1ecd3 100644 --- a/tests/FeatureTests/BaseRequestTestCase.php +++ b/tests/FeatureTests/BaseRequestTestCase.php @@ -8,9 +8,24 @@ abstract class BaseRequestTestCase extends TestCase { + private const IGNORED_HEAD_HEADERS = ['X-Debug-Token', 'X-Debug-Token-Link', 'Date']; + public function runGetRequest(string $uri, string $token): ResponseInterface { - return $this->runRequest('GET', $uri, $token); + $headRequest = $this->runRequest('HEAD', $uri, $token); + $getRequest = $this->runRequest('GET', $uri, $token); + + $headHeaders = $headRequest->getHeaders(); + $getHeaders = $getRequest->getHeaders(); + foreach ($headHeaders as $key => $value) { + $this->assertArrayHasKey($key, $getHeaders); + if (in_array($key, self::IGNORED_HEAD_HEADERS)) { + continue; + } + $this->assertSame($value, $getHeaders[$key]); + } + + return $getRequest; } public function runPostRequest(string $uri, string $token, array $data): ResponseInterface