mrgoodbytes8667 / test-common-faker
模拟数据提供者
v0.6.0
2024-08-02 16:20 UTC
Requires
- php: ^8.1
- mrgoodbytes8667/faker-providers: ^0.6
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.58
- rector/rector: ^1.0
- symfony/test-pack: ^1.0.9
Conflicts
- phpunit/phpunit: <9.5 || 9.5.8
This package is auto-updated.
Last update: 2024-09-02 16:36:12 UTC
README
提供 Faker 测试助手
安装
请确保全局已安装 Composer,具体请参考 Composer 文档中的 安装章节。
打开命令行,进入项目目录并执行
$ composer require mrgoodbytes8667/test-common-faker --dev
用法
class SampleTest extends KernelTestCase { use \Bytes\Common\Faker\TestFakerTrait; public function testSomething() { $number = $this->faker->numberBetween(); self::assertLessThan(0, $number); } }
注意:@var 对 IDE 自动完成很有帮助
与 PHPUnit 一起使用
如果您在每次测试中都使用 $faker
,可以使用 TestFakerTrait
在每个测试之前/之后设置/拆卸 $this->faker
。将 $this->providers
声明为一个数组,包含除 MiscProvider
之外的其他提供者,当使用此特性时自动添加它们。
许可证
Test Common Faker 由 MrGoodBytes 发布,遵循 Creative Commons Attribution-NonCommercial 4.0 国际许可证。
基于 https://github.com/mrgoodbytes8667/test-common-faker 的工作。