定制 qratorlabs/smocky-phpunit 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

qratorlabs/smocky-phpunit

最新稳定版本:2.1.0

Composer 安装命令:

composer require qratorlabs/smocky-phpunit

包简介

Extension to wire up Smocky and PHPUnit

README 文档

README

This is a helper library-helper for QratorLabs\Smocky that allows you to use Smocky and PHPUnit together with less boilerplate code.

Installation

composer require --dev "qratorlabs/smocky-phpunit:^1.0||^2.0"

Versioning

This library follows SemVer. But major versions are used to indicate compatibility with PHPUnit versions:

  • 1.x is compatible with PHPUnit 9.6...12.0.8
  • 2.0 is compatible with PHPUnit 12.0.9...12.4.x
  • 2.1 is compatible with PHPUnit 12.5.0...

Usage

To use with PHPUnit:

  • MockedMethod to mock method "globally" and use PHPUnit's *Mockers - expects/willReturn/willReturnCallback/...
  • MockedFunction

MockedMethod

The main target is to make mocking static methods easy and feels-n-looks like using PHPUnit.

public function testSomeTest(): void {
    $methodMock = new MockedMethod($this, SomeClass::class, 'someMethod', once());
    $methodMock->getMocker()->willReturn(10);

    SomeClass::someMethod(); // will return `10`
    
    SomeClass::someMethod(); // will cause error (expectation - one call)
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-03-20