CakePHP
  • 文档
    • 书籍
    • API
    • 视频
    • 报告安全问题
    • 隐私政策
    • 标识 & 商标
  • 商业解决方案
  • 纪念品
  • 公路旅行
  • 团队
  • 社区
    • 社区
    • 参与
    • 问题 (Github)
    • 烘焙坊
    • 特色资源
    • 培训
    • 聚会
    • 我的 CakePHP
    • CakeFest
    • 新闻稿
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • 帮助 & 支持
    • 论坛
    • Stack Overflow
    • IRC
    • Slack
    • 付费支持
CakePHP

C CakePHP 5.1 Chiffon API

  • 项目
    • CakePHP
      • CakePHP
      • Chronos
      • Elastic Search
      • 队列
  • 版本
    • 5.1
      • 5.1
      • 5.0
      • 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

命名空间

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

特性 HttpClientTrait

定义模拟响应,并自动清除模拟。

命名空间: Cake\Http\TestSuite

方法摘要

  • cleanupMockResponses() public

    重置模拟响应

  • mockClientDelete() public

    为 DELETE 请求添加模拟响应。

  • mockClientGet() public

    为 GET 请求添加模拟响应。

  • mockClientPatch() public

    为 PATCH 请求添加模拟响应。

  • mockClientPost() public

    为 POST 请求添加模拟响应。

  • mockClientPut() public

    为 PUT 请求添加模拟响应。

  • newClientResponse() public

    创建一个新的响应。

方法详细

cleanupMockResponses() ¶ public

cleanupMockResponses(): void

重置模拟响应

返回值
void

mockClientDelete() ¶ public

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

为 DELETE 请求添加模拟响应。

参数
string $url

要模拟的 URL

Cake\Http\Client\Response $response

模拟的响应。

array<string, mixed> $options optional

其他选项。参见 Client::addMockResponse()

返回值
void

mockClientGet() ¶ public

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

为 GET 请求添加模拟响应。

参数
string $url

要模拟的 URL

Cake\Http\Client\Response $response

模拟的响应。

array<string, mixed> $options optional

其他选项。参见 Client::addMockResponse()

返回值
void

mockClientPatch() ¶ public

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

为 PATCH 请求添加模拟响应。

参数
string $url

要模拟的 URL

Cake\Http\Client\Response $response

模拟的响应。

array<string, mixed> $options optional

其他选项。参见 Client::addMockResponse()

返回值
void

mockClientPost() ¶ public

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

为 POST 请求添加模拟响应。

参数
string $url

要模拟的 URL

Cake\Http\Client\Response $response

模拟的响应。

array<string, mixed> $options optional

其他选项。参见 Client::addMockResponse()

返回值
void

mockClientPut() ¶ public

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

为 PUT 请求添加模拟响应。

参数
string $url

要模拟的 URL

Cake\Http\Client\Response $response

模拟的响应。

array<string, mixed> $options optional

其他选项。参见 Client::addMockResponse()

返回值
void

newClientResponse() ¶ public

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

创建一个新的响应。

参数
int $code optional

要使用的响应码。默认为 200

list<string> $headers optional

响应的标题列表。例如 Content-Type: application/json

string $body optional

响应的正文。

返回值
Cake\Http\Client\Response
OpenHub
Pingping
Linode
  • 商业解决方案
  • 展示
  • 文档
  • 书籍
  • API
  • 视频
  • 报告安全问题
  • 隐私政策
  • 标识 & 商标
  • 社区
  • 参与
  • 问题 (Github)
  • 烘焙坊
  • 特色资源
  • 培训
  • 聚会
  • 我的 CakePHP
  • CakeFest
  • 新闻稿
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • 帮助 & 支持
  • 论坛
  • Stack Overflow
  • IRC
  • Slack
  • 付费支持

使用 CakePHP API 文档 生成