ssaweb/phpunit-slot 问题修复 & 功能扩展

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

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

ssaweb/phpunit-slot

最新稳定版本:v1.1.0

Composer 安装命令:

composer require ssaweb/phpunit-slot

包简介

A package to help you catch method parameters for testing.

README 文档

README

A feature that allows you to capture method parameters as you would do with Mockk capture() - https://mockk.io/#capturing

Well, I just created this package to make parameter assertions more readable (my personal thought).

Of course you can say doing the way below already work, but I dunno when there's a need to add a callback for each parameter it didn't look well to me.

That's why I decided to create this package and make this more the way I was used to in Kotlin (with the mockk library =)

$mock
    ->expects($this->once())
    ->method('foo')
    ->with(self::callback(function ($value): bool {
        self::assertEquals('value', $value);
        return true;
    }))

Instead of that I am doing something like this

$slot = new Slot();

$mock
    ->expects($this->once())
    ->method('foo')
    ->with($slot->capture())

//other mock declarations

//then
self::assertEquals(1, $slot->captured);

v1.1.0+ It now supports multiple method calls. So, if your method is being called more than once, the captured value will be an array of each capture value.

$slot = new Slot();

$mock
    ->expects($this->any())
    ->method('foo')
    ->with($slot->capture())

//other mock declarations

//then
self::assertEquals(1, $slot->captured[0]);
self::assertEquals(2, $slot->captured[1]);

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-06-28