Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Client Integration Tests Laravel Package

guzzle/client-integration-tests

Integration test suite for Guzzle HTTP client implementations. Provides shared fixtures and tests to verify PSR-7/PSR-18 behavior, compatibility, and edge cases across adapters and transports. Designed for package maintainers validating clients.

Deep Wiki
Context7

Getting Started

This package is not a runtime dependency—it’s a development-only tool for testing HTTP client behavior. It provides reusable integration test suites (e.g., for PSR-18 compliant clients like guzzlehttp/psr7 or symfony/http-client). To begin:

  1. Require it as a dev dependency:
    composer require --dev guzzle/client-integration-tests
  2. Extend the provided test cases (e.g., GuzzleHttp\IntegrationTests\IntegrationTestCase) in your own test suite.
  3. Implement the required abstract methods (e.g., createClient() and getUri()) to return your PSR-18 client instance and base URI.

Start by running the included example tests (often in tests/Integration/) to verify setup before adding your custom tests.

Implementation Patterns

  • Custom Client Testing: Write integration tests that mirror real-world API calls—e.g., test timeout handling, retry logic, or middleware behavior—by subclassing IntegrationTestCase.
  • Reusability Across Clients: Since tests are PSR-18-based, the same test suite can validate multiple HTTP clients (e.g., Guzzle, PHP-HTTP, Symfony’s HttpClient) by passing different client instances in createClient().
  • Assertion Helpers: Use built-in assertions like assertResponseContains() or assertResponseHeader() for clean, consistent test expectations.
  • Environment Configuration: Leverage environment variables (e.g., INTEGRATION_TEST_URL) to switch between mock endpoints (e.g., httpbin.org) or local test servers.

Gotchas and Tips

  • No Standalone CLI: This package does not provide a runner or binary. You integrate its classes directly into your PHPUnit test suite.
  • Test Environment Dependencies: Ensure your test environment can reach external endpoints (e.g., httpbin.org) or configure a local mock server via createClient() to avoid flaky tests.
  • Abstract Method Traps: Forgetting to implement getUri() or returning an invalid URI will cause silent failures—always validate return values.
  • PHP Version Compatibility: This package may lag behind latest Guzzle/Guzzle PSR-7/PSR-18 changes. Check composer.json’s require-dev constraints to confirm PHP version support.
  • Extensibility: Override setUp(), tearDown(), or getExpectedException() in your test class to inject custom setup (e.g., clearing interceptors) or test edge cases (e.g., network failures).
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport