otezvikentiy/codeception-symfony-http-client-mock
最新稳定版本:1.3.0
Composer 安装命令:
composer require otezvikentiy/codeception-symfony-http-client-mock
包简介
Codeception Module for Mocking HttpClient in Symfony
README 文档
README
Mock module for Symfony + Codeception + HttpClient
Installation
composer require otezvikentiy/codeception-symfony-http-client-mock --dev
Configuration
- Add to your Functional.suite.yaml
modules: enabled: - OtezVikentiy\CodeceptionHttpMock\HttpMockModule config: OtezVikentiy\CodeceptionHttpMock\HttpMockModule: http_client_service_name: 'http_client'
- Configure your Symfony services.yaml as follows
when@test: services: _defaults: public: true # turn off project factory # replace this path with the path to your factory App\Infrastructure\HttpClient\HttpClientFactory: class: stdClass # replace the client with mock http_client: class: OtezVikentiy\CodeceptionHttpMock\HttpClient\HttpClientMock factory: ['OtezVikentiy\CodeceptionHttpMock\HttpClient\HttpClientMock', 'getInstance']
- Usage in tests
final public function someTest(FunctionalTester $I): void { $I->expectHttpRequest('DELETE', '/example/v1/orders') ->withBody(json_encode([ 'id' => '01f5cfeb-007e-11e5-82bf-9c8e99f9e058', ])) ->respondWith(status: 200, body: json_encode([ 'Result' => 'Ok', ], JSON_UNESCAPED_UNICODE)); $I->sendPost('/api/v3', '{"field": "value"}'; $I->seeResponseCodeIs(200); }
统计信息
- 总下载量: 14
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-04-25