http-interop/http-factory-tests
PHPUnit test suite to verify PSR-17 HTTP factory implementations. Configure phpunit.xml with constants pointing to your Request/Response/ServerRequest/Stream/UploadedFile/Uri factory classes, then run the included integration tests from vendor.
Add this package as a dev dependency to your project:
composer require --dev http-interop/http-factory-tests
Then, create a test class that extends one of the provided base test suites (e.g., HttpFactoryTestCase) and implement the abstract createFactory(): FactoryInterface method to return your PSR-17 factory implementation. Run tests with phpunit. This immediately validates compliance for ServerRequestFactoryInterface, ResponseFactoryInterface, StreamFactoryInterface, and UriFactoryInterface.
Note for PHP 8 / PHPUnit 9 users: Version 0.7.0 now supports PHP 8 and PHPUnit 9, so ensure your phpunit.xml or phpunit CLI version aligns accordingly. If upgrading from earlier versions, verify that your test environment does not conflict with PHP 8+ type hints or scalar return types (e.g., string in getUri() return declarations).
HttpFactoryTestCase in your tests/ directory and override createFactory() to test multiple factory implementations (e.g., Nyholm/psr7, Laminas/Diactoros, Symfony/HttpFoundation adapters).#[Used], readonly classes) in your test implementations without interference from the test suite.psr/http-factory v1.0.x is used; newer PSR-7/PSR-17 clarifications (e.g., withUploadedFiles() immutability) may still require manual validation.withHeader(), withStatus()) with your own tests, as PSR-7 factories don’t define mutator validation.phpunit.xml includes your tests/ dir in <php><includePath> or use a proper bootstrap—especially important if using PHP 8’s class autoloading stricter rules.testCreateUploadedFile() for special multipart handling) to relax or tighten expectations without duplicating the whole suite.php-http/discovery tests and nyholm/psr7-factory-bench to catch edge-case deviations across environment-specific factories (e.g., Apache vs. CLI SAPI).PHPUNIT_VERSION=9.6 or higher) to avoid fatal errors from removed APIs (e.g., PHPUnit\Framework\TestCase::getMock()).How can I help you explore Laravel packages today?