php-http/psr7-integration-tests
A PHPUnit-based integration test suite for PSR-7 HTTP message implementations. It verifies requests, responses, streams, URIs, and headers against the PSR-7 specification, helping libraries like Guzzle, Laminas, Slim, and Nyholm ensure compliance.
Begin by requiring the package in your test environment:
composer require --dev php-http/psr7-integration-tests
If you are using PHPUnit 13, require version 1.5.2 or newer; earlier releases may conflict with PHPUnit 13 during Composer resolution.
Then, in your phpunit.xml, include the test suite and create a minimal test class that extends Http\Tests\Integration\Psr7IntegrationTestCase. The class must implement a createMessageFactory() method returning your PSR-7 message factory (e.g., Symfony HttpClient, Nyholm/psr7, Guzzle). Run tests via phpunit --testsuite=psr7-integration.
First use case: Validate a new or custom PSR-7 implementation (e.g., MyProject\Psr7\Factory) before publishing it — run integration tests to catch deviations from PSR-7 standards in common operations like withHeader(), stream buffering, or URI mutation.
Psr7IntegrationTestCase, implement required factory methods, and optionally override setUp() to configure environment-specific behavior (e.g., mock file system for stream tests).HasPsr7Compliance) to reuse across multiple packages (e.g., HTTP clients, middleware libraries).1.5.2, include PHPUnit versions in your CI matrix if you support multiple major PHPUnit releases.php-http/discovery), run integration tests against the resolved factory to verify runtime behavior, not just compile-time interfaces.php-http/psr7-integration-tests 1.5.2+. If Composer reports a conflict, check the locked package version before changing your PHPUnit constraint.with*() methods mutate the original object. If tests break, inspect return values and reference identity.fopen('php://temp', 'r+') or large buffers may fail in environments with limited memory limits — adjust memory_limit for full coverage.MessageFactoryInterface and StreamFactoryInterface — the suite validates both.Tests\Integration\ namespace; IDE autocomplete may misfire if tests are added at root level.provide*Data() methods in your subclass to add custom edge cases (e.g., non-standard headers, malformed URIs), while retaining core compliance checks.--debug with PHPUnit to trace failures back to exact immutability or type violations.How can I help you explore Laravel packages today?