CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (Github)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 4.4 Strawberry API

  • Project:
    • CakePHP
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 4.4
      • 5.2
      • 5.1
      • 5.0
      • 4.6
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Global
  • Cake
    • Auth
    • Cache
    • Collection
    • Command
    • Console
    • Controller
    • Core
    • Database
    • Datasource
    • Error
    • Event
    • Filesystem
    • Form
    • Http
      • Client
      • Cookie
      • Exception
      • Middleware
      • Session
      • TestSuite
    • I18n
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • Shell
    • TestSuite
    • Utility
    • Validation
    • View

Trait HttpClientTrait

Define mock responses and have mocks automatically cleared.

Namespace: Cake\Http\TestSuite

Method Summary

  • cleanupMockResponses() public

    Resets mocked responses

  • mockClientDelete() public

    Add a mock response for a DELETE request.

  • mockClientGet() public

    Add a mock response for a GET request.

  • mockClientPatch() public

    Add a mock response for a PATCH request.

  • mockClientPost() public

    Add a mock response for a POST request.

  • mockClientPut() public

    Add a mock response for a PUT request.

  • newClientResponse() public

    Create a new response.

Method Detail

cleanupMockResponses() ¶ public

cleanupMockResponses(): void

Resets mocked responses

Returns
void

mockClientDelete() ¶ public

mockClientDelete(string $url, Cake\Http\Client\Response $response, array<string, mixed> $options = []): void

Add a mock response for a DELETE request.

Parameters
string $url

The URL to mock

Cake\Http\Client\Response $response

The response for the mock.

array<string, mixed> $options optional

Additional options. See Client::addMockResponse()

Returns
void

mockClientGet() ¶ public

mockClientGet(string $url, Cake\Http\Client\Response $response, array<string, mixed> $options = []): void

Add a mock response for a GET request.

Parameters
string $url

The URL to mock

Cake\Http\Client\Response $response

The response for the mock.

array<string, mixed> $options optional

Additional options. See Client::addMockResponse()

Returns
void

mockClientPatch() ¶ public

mockClientPatch(string $url, Cake\Http\Client\Response $response, array<string, mixed> $options = []): void

Add a mock response for a PATCH request.

Parameters
string $url

The URL to mock

Cake\Http\Client\Response $response

The response for the mock.

array<string, mixed> $options optional

Additional options. See Client::addMockResponse()

Returns
void

mockClientPost() ¶ public

mockClientPost(string $url, Cake\Http\Client\Response $response, array<string, mixed> $options = []): void

Add a mock response for a POST request.

Parameters
string $url

The URL to mock

Cake\Http\Client\Response $response

The response for the mock.

array<string, mixed> $options optional

Additional options. See Client::addMockResponse()

Returns
void

mockClientPut() ¶ public

mockClientPut(string $url, Cake\Http\Client\Response $response, array<string, mixed> $options = []): void

Add a mock response for a PUT request.

Parameters
string $url

The URL to mock

Cake\Http\Client\Response $response

The response for the mock.

array<string, mixed> $options optional

Additional options. See Client::addMockResponse()

Returns
void

newClientResponse() ¶ public

newClientResponse(int $code = 200, array<string> $headers = [], string $body = ''): Cake\Http\Client\Response

Create a new response.

Parameters
int $code optional

The response code to use. Defaults to 200

array<string> $headers optional

A list of headers for the response. Example Content-Type: application/json

string $body optional

The body for the response.

Returns
Cake\Http\Client\Response
OpenHub
Pingping
Linode
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (Github)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs