gyro/phake-attributes
最新稳定版本:v2.0
Composer 安装命令:
composer require --dev gyro/phake-attributes
包简介
A #[Mock] attribute for Phake inside PHPUnit and helpers.
关键字:
README 文档
README
This extension for Phake provides an attribute #[Mock] for properties that
can be used in PHPUnit testcases via a trait that adds a before listener:
use Gyro\PhakeAttributes\Mock; use Gyro\PhakeAttributes\PhakeAttributes; use PHPUnit\Framework\TestCase; class MyServiceTestCase extends TestCase { use PhakeAttributes; #[Mock] // during setup phase in PHPUnit will call Phake::mock(MyDependencyService::class) private MyDependencyService $myDependency; public function testMyServiceMethod() : void { \Phake::when($this->myDependency)->foo()->thenReturn('bar'); // this uses named arguments and array expansion to pass ctor arguments // reflection is used to find the types needed for each argument and the // properties and mocks in current test are searched for matches based // on variable name or type. $service = new MyService(...$this->mockArgumentsFor(Myservice::class)); // if you dont want to type that much: $service = $this->newInstanceWithMockedArgumentsFor(MyService::class); } }
统计信息
- 总下载量: 51.76k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-07-02