Add comprehensive unit test suite - #5
Conversation
Co-authored-by: liopoos <12404909+liopoos@users.noreply.github.com>
Co-authored-by: liopoos <12404909+liopoos@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
This PR adds a comprehensive unit test suite for the Booze HTTP library, implementing 50 tests with 83 assertions covering all library components. The test infrastructure uses PHPUnit 9.6 with proper autoloading and mocking via Guzzle's MockHandler to avoid external dependencies.
Key Changes:
- Added PHPUnit 9.6 test infrastructure with configuration and PSR-4 autoloading
- Created comprehensive test coverage for all HTTP methods, middleware, response parsing, and exception handling
- Added testing documentation and updated .gitignore for test artifacts
Reviewed Changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| phpunit.xml | Configures PHPUnit with test discovery, coverage settings, and bootstrap |
| composer.json | Adds PHPUnit dev dependency, test autoloading, and updates PHP version to support 8.0+ |
| tests/README.md | Provides test execution documentation and suite structure overview |
| README.md | Adds testing section with quick reference to running tests |
| .gitignore | Excludes PHPUnit cache and coverage report artifacts |
| tests/Unit/ClientTest.php | Tests Client class constructor, header chaining, and middleware integration |
| tests/Unit/Http/HttpClientTest.php | Tests all HTTP verbs and content type handling (form, JSON, multipart) |
| tests/Unit/Http/Middleware/RequestHandlerMiddlewareTest.php | Tests request header injection and preservation |
| tests/Unit/Http/Middleware/ResponseHandlerMiddlewareTest.php | Tests success/error response handling and exception mapping |
| tests/Unit/Utils/ResponseStreamTest.php | Tests response parsing for JSON, XML, and plain text formats |
| tests/Unit/Exception/ExceptionTest.php | Validates exception hierarchy and proper inheritance |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@copilot apply changes based on the comments in this thread |
The test method name has been updated from Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Implements unit testing infrastructure and comprehensive test coverage for all library components.
Changes
Test Infrastructure
tests/Unit/composer.jsonwithautoload-devPSR-4 mapping and PHP 8.0+ supportTest Coverage (50 tests, 83 assertions)
ClientTest: Constructor, middleware integration, header chainingHttpClientTest: All HTTP verbs (GET/POST/PUT/PATCH/DELETE), content types (form/JSON/multipart)ResponseStreamTest: JSON/XML/plain text parsing, malformed input handlingResponseHandlerMiddlewareTest: Success/error response handling, status code mapping to exceptionsRequestHandlerMiddlewareTest: Header injection, header preservationExceptionTest: Exception hierarchy validationDocumentation
tests/README.mdwith test execution examplesRunning Tests
./vendor/bin/phpunit ./vendor/bin/phpunit --testdox # Detailed outputAll tests use Guzzle's MockHandler to avoid external HTTP dependencies. The test suite validates the entire request/response lifecycle including middleware transformations and error handling.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
https://api.github.com/repos/guzzle/guzzle/zipball/d281ed313b989f213357e3be1a179f02196ac99b/usr/bin/php8.3 -n -c /tmp/AqM3ch /usr/bin/composer install --ignore-platform-reqs(http block)/usr/bin/php8.3 -n -c /tmp/3kHjwV /usr/bin/composer install --ignore-platform-reqs --no-plugins(http block)https://api.github.com/repos/guzzle/promises/zipball/6ea8dd08867a2a42619d65c3deb2c0fcbf81c8f8/usr/bin/php8.3 -n -c /tmp/AqM3ch /usr/bin/composer install --ignore-platform-reqs(http block)/usr/bin/php8.3 -n -c /tmp/3kHjwV /usr/bin/composer install --ignore-platform-reqs --no-plugins(http block)https://api.github.com/repos/guzzle/psr7/zipball/a70f5c95fb43bc83f07c9c948baa0dc1829bf201/usr/bin/php8.3 -n -c /tmp/AqM3ch /usr/bin/composer install --ignore-platform-reqs(http block)/usr/bin/php8.3 -n -c /tmp/3kHjwV /usr/bin/composer install --ignore-platform-reqs --no-plugins(http block)https://api.github.com/repos/liopoos/http-code/zipball/bc0146d73ebb5071ea84d49a4c432a376a52566a/usr/bin/php8.3 -n -c /tmp/3kHjwV /usr/bin/composer install --ignore-platform-reqs --no-plugins(http block)https://api.github.com/repos/nikic/PHP-Parser/zipball/8eea230464783aa9671db8eea6f8c6ac5285794b/usr/bin/php8.3 -n -c /tmp/3kHjwV /usr/bin/composer install --ignore-platform-reqs --no-plugins(http block)https://api.github.com/repos/phar-io/manifest/zipball/97803eca37d319dfa7826cc2437fc020857acb53/usr/bin/php8.3 -n -c /tmp/3kHjwV /usr/bin/composer install --ignore-platform-reqs --no-plugins(http block)https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74/usr/bin/php8.3 -n -c /tmp/3kHjwV /usr/bin/composer install --ignore-platform-reqs --no-plugins(http block)https://api.github.com/repos/php-fig/http-client/zipball/bb5906edc1c324c9a05aa0873d40117941e5fa90/usr/bin/php8.3 -n -c /tmp/3kHjwV /usr/bin/composer install --ignore-platform-reqs --no-plugins(http block)https://api.github.com/repos/php-fig/http-factory/zipball/e616d01114759c4c489f93b099585439f795fe35/usr/bin/php8.3 -n -c /tmp/AqM3ch /usr/bin/composer install --ignore-platform-reqs(http block)/usr/bin/php8.3 -n -c /tmp/3kHjwV /usr/bin/composer install --ignore-platform-reqs --no-plugins(http block)https://api.github.com/repos/php-fig/http-message/zipball/402d35bcb92c70c026d1a6a9883f06b2ead23d71/usr/bin/php8.3 -n -c /tmp/AqM3ch /usr/bin/composer install --ignore-platform-reqs(http block)/usr/bin/php8.3 -n -c /tmp/3kHjwV /usr/bin/composer install --ignore-platform-reqs --no-plugins(http block)https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822/usr/bin/php8.3 -n -c /tmp/3kHjwV /usr/bin/composer install --ignore-platform-reqs --no-plugins(http block)https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5/usr/bin/php8.3 -n -c /tmp/3kHjwV /usr/bin/composer install --ignore-platform-reqs --no-plugins(http block)https://api.github.com/repos/sebastianbergmann/comparator/zipball/fa0f136dd2334583309d32b62544682ee972b51a/usr/bin/php8.3 -n -c /tmp/3kHjwV /usr/bin/composer install --ignore-platform-reqs --no-plugins(http block)https://api.github.com/repos/sebastianbergmann/complexity/zipball/25f207c40d62b8b7aa32f5ab026c53561964053a/usr/bin/php8.3 -n -c /tmp/3kHjwV /usr/bin/composer install --ignore-platform-reqs --no-plugins(http block)https://api.github.com/repos/sebastianbergmann/diff/zipball/ba01945089c3a293b01ba9badc29ad55b106b0bc/usr/bin/php8.3 -n -c /tmp/3kHjwV /usr/bin/composer install --ignore-platform-reqs --no-plugins(http block)https://api.github.com/repos/sebastianbergmann/environment/zipball/830c43a844f1f8d5b7a1f6d6076b784454d8b7ed/usr/bin/php8.3 -n -c /tmp/3kHjwV /usr/bin/composer install --ignore-platform-reqs --no-plugins(http block)https://api.github.com/repos/sebastianbergmann/exporter/zipball/78c00df8f170e02473b682df15bfcdacc3d32d72/usr/bin/php8.3 -n -c /tmp/3kHjwV /usr/bin/composer install --ignore-platform-reqs --no-plugins(http block)https://api.github.com/repos/sebastianbergmann/global-state/zipball/bca7df1f32ee6fe93b4d4a9abbf69e13a4ada2c9/usr/bin/php8.3 -n -c /tmp/3kHjwV /usr/bin/composer install --ignore-platform-reqs --no-plugins(http block)https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/e1e4a170560925c26d424b6a03aed157e7dcc5c5/usr/bin/php8.3 -n -c /tmp/3kHjwV /usr/bin/composer install --ignore-platform-reqs --no-plugins(http block)https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/5c9eeac41b290a3712d88851518825ad78f45c71/usr/bin/php8.3 -n -c /tmp/3kHjwV /usr/bin/composer install --ignore-platform-reqs --no-plugins(http block)https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/b4f479ebdbf63ac605d183ece17d8d7fe49c15c7/usr/bin/php8.3 -n -c /tmp/3kHjwV /usr/bin/composer install --ignore-platform-reqs --no-plugins(http block)https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/85402a822d1ecf1db1096959413d35e1c37cf1a5/usr/bin/php8.3 -n -c /tmp/3kHjwV /usr/bin/composer install --ignore-platform-reqs --no-plugins(http block)https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf/usr/bin/php8.3 -n -c /tmp/3kHjwV /usr/bin/composer install --ignore-platform-reqs --no-plugins(http block)https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/5a10147d0aaf65b58940a0b72f71c9ac0423cc67/usr/bin/php8.3 -n -c /tmp/3kHjwV /usr/bin/composer install --ignore-platform-reqs --no-plugins(http block)https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a1a54a473501ef4cdeaae4e06891674114d79db8/usr/bin/php8.3 -n -c /tmp/3kHjwV /usr/bin/composer install --ignore-platform-reqs --no-plugins(http block)https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1/usr/bin/php8.3 -n -c /tmp/3kHjwV /usr/bin/composer install --ignore-platform-reqs --no-plugins(http block)https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/05d5692a7993ecccd56a03e40cd7e5b09b1d404e/usr/bin/php8.3 -n -c /tmp/AqM3ch /usr/bin/composer install --ignore-platform-reqs(http block)/usr/bin/php8.3 -n -c /tmp/3kHjwV /usr/bin/composer install --ignore-platform-reqs --no-plugins(http block)https://api.github.com/repos/sebastianbergmann/type/zipball/75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7/usr/bin/php8.3 -n -c /tmp/AqM3ch /usr/bin/composer install --ignore-platform-reqs(http block)/usr/bin/php8.3 -n -c /tmp/3kHjwV /usr/bin/composer install --ignore-platform-reqs --no-plugins(http block)https://api.github.com/repos/sebastianbergmann/version/zipball/c6c1022351a901512170118436c764e473f6de8c/usr/bin/php8.3 -n -c /tmp/AqM3ch /usr/bin/composer install --ignore-platform-reqs(http block)/usr/bin/php8.3 -n -c /tmp/3kHjwV /usr/bin/composer install --ignore-platform-reqs --no-plugins(http block)https://api.github.com/repos/symfony/deprecation-contracts/zipball/605389f2a7e5625f273b53960dc46aeaf9c62918/usr/bin/php8.3 -n -c /tmp/AqM3ch /usr/bin/composer install --ignore-platform-reqs(http block)/usr/bin/php8.3 -n -c /tmp/3kHjwV /usr/bin/composer install --ignore-platform-reqs --no-plugins(http block)https://api.github.com/repos/theseer/tokenizer/zipball/737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2/usr/bin/php8.3 -n -c /tmp/3kHjwV /usr/bin/composer install --ignore-platform-reqs --no-plugins(http block)mirrors.aliyun.com/usr/bin/php8.3 -n -c /tmp/AqM3ch /usr/bin/composer install --ignore-platform-reqs(dns block)/usr/bin/php8.3 -n -c /tmp/3kHjwV /usr/bin/composer install --ignore-platform-reqs --no-plugins(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.