Skip to content

Releases: aksoyih/http-mock

Release list

v2.0.0

Choose a tag to compare

@aksoyih aksoyih released this 17 Mar 11:43

HTTP Mock v2.0.0

A complete rewrite of aksoyih/http-mock with a modular architecture, flexible request matching, full verification support, and adapters for PSR-18, Guzzle, and Symfony HttpClient.

Breaking Changes

  • PHP 8.4+ required (was 8.1+)
  • MockBuilder replaced by ResponseBuilder with explicit register() instead of __destruct() magic
  • Removed withDelay() / withGlobalError() — v2 focuses on response mocking and verification

New Features

  • Static facade API — HttpMock::when(), HttpMock::fake(), HttpMock::verify()
  • Flexible request matching — exact, wildcard (*, **), regex (#pattern#), and callable matchers via HttpMock::whenMatching()
  • Request verification — assertCalled(), assertCalledTimes(), assertNotCalled(), and expect() constraints (times, atLeast, atMost)
  • PSR-18 adapter — HttpMock::createClient() returns a Psr\Http\Client\ClientInterface
  • Guzzle adapter — HttpMock::createGuzzleHandler() for Guzzle's HandlerStack
  • Symfony adapter — HttpMock::createSymfonyClient() returns a Symfony\Contracts\HttpClient\HttpClientInterface
  • Unmatched request handling — strict mode (default), 404 fallback, or custom callable
  • MocksHttp PHPUnit trait — automatic reset() after each test
  • HttpMock::scoped() — auto-reset via try/finally
  • HttpMock::fake() — shorthand for defining multiple mocks at once

Quality

  • PHPStan level 9 — zero errors
  • Laravel Pint (PSR-12) code style
  • 84 tests, 136 assertions (unit + integration + feature)
  • GitHub Actions CI pipeline

Dependencies

  • psr/http-client ^1.0
  • psr/http-factory ^1.0
  • nyholm/psr7 ^1.0
  • Optional: guzzlehttp/guzzle ^7.0, symfony/http-client ^7.0

1.0.0

Choose a tag to compare

@aksoyih aksoyih released this 06 Feb 08:31
initial commit