citruslab/mokkd 问题修复 & 功能扩展

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

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

citruslab/mokkd

最新稳定版本:v0.0.2

Composer 安装命令:

composer require citruslab/mokkd

包简介

A library for mocking free-standing functions in PHP

README 文档

README

Mokkd is pre-release software.

Mokkd is licensed under the Apache License 2.0. See the LICENSE file.

Aims to do for free functions what Mockery does for classes. Test doubles for functions can be quickly built using a fluent interface. For example, to mock the time() built-in function so that it returns 0, use:

$time = Mokkd::func("time")
    ->returning(0);

Basic usage scenarios are covered in this readme. See the documentation for more.

Return successive array elements

$time = Mokkd::func("time")
    ->returningFrom([0, 1, 2])

Return a mapped value

$getEnv = Mokkd::func("getenv"
    ->returningMappedValueFrom(
        [
            "host" => "example.com",
            "secret" => "fake-secret"
        ],
        0,
    )

Completely replace a function

$time = Mokkd::func("time")
    ->returningUsing(static function(): int {
        static $count = 0;
        return 60 * $count++;
    })

Setting expectations

Control call count

$time = Mokkd::func("time")
    ->times(3)
    ->returning(0);

Convenience once() and twice()

$time = Mokkd::func("time")
    ->once()
    ->returning(0);
$time = Mokkd::func("time")
    ->twice()
    ->returning(0);

Expect specified arguments

$getEnv = Mokkd::func("getenv")
    ->expects("host")
    ->returning("example.com")

Matching arguments

$getEnv = Mokkd::func("substr")
    ->expects(Mokkd::isString(), 0, Mokkd::isIntGreaterThan(2))
    ->returning("leftmost")

Allowing unmatched calls

$getEnv = Mokkd::func("getenv")
    ->expects("host")
    ->returning("example.com")
    ->withoutBlocking()

统计信息

  • 总下载量: 33
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2025-10-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固