otezvikentiy/codeception-symfony-http-client-mock 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

  1. Add to your Functional.suite.yaml
modules:
    enabled:
        - OtezVikentiy\CodeceptionHttpMock\HttpMockModule
    config:
        OtezVikentiy\CodeceptionHttpMock\HttpMockModule:
            http_client_service_name: 'http_client'
  1. 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']
  1. 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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-04-25