Priority: 🟠 High
Description
The library ships four exception classes but none have a dedicated test file:
src/Fetch/Exceptions/ClientException.php
src/Fetch/Exceptions/HttpException.php
src/Fetch/Exceptions/NetworkException.php
src/Fetch/Exceptions/RequestException.php
These classes appear in the codebase as catch targets and thrown types, but their construction, message formatting, code propagation, and $previous chaining are never directly validated. If a refactor changes a constructor signature or message format, no test will catch it.
This gap is particularly important given issue #81 ([HIGH-1]), which recommends throwing domain exceptions instead of RuntimeException — that change has no test coverage to land on.
Recommended Fix
Create tests/Unit/Exceptions/ExceptionTest.php (or one file per class) covering:
// Example structure
it('constructs with message and code', function () {
$e = new NetworkException('Connection refused', 503);
expect($e->getMessage())->toBe('Connection refused');
expect($e->getCode())->toBe(503);
});
it('preserves $previous exception chain', function () {
$previous = new \RuntimeException('original');
$e = new NetworkException('Wrapped', 0, $previous);
expect($e->getPrevious())->toBe($previous);
});
it('extends the correct parent class', function () {
expect(new NetworkException(''))->toBeInstanceOf(\RuntimeException::class);
});
Test all four classes. Confirm the inheritance hierarchy matches the documented contract.
Related
Issue #81 — HIGH-1: Guzzle exceptions re-wrapped as RuntimeException
Priority: 🟠 High
Description
The library ships four exception classes but none have a dedicated test file:
src/Fetch/Exceptions/ClientException.phpsrc/Fetch/Exceptions/HttpException.phpsrc/Fetch/Exceptions/NetworkException.phpsrc/Fetch/Exceptions/RequestException.phpThese classes appear in the codebase as catch targets and thrown types, but their construction, message formatting, code propagation, and
$previouschaining are never directly validated. If a refactor changes a constructor signature or message format, no test will catch it.This gap is particularly important given issue #81 ([HIGH-1]), which recommends throwing domain exceptions instead of
RuntimeException— that change has no test coverage to land on.Recommended Fix
Create
tests/Unit/Exceptions/ExceptionTest.php(or one file per class) covering:Test all four classes. Confirm the inheritance hierarchy matches the documented contract.
Related
Issue #81 — HIGH-1: Guzzle exceptions re-wrapped as RuntimeException