richcongress / fixture-test
为对象生成随机且具有意义的随机数据
Requires
- php: ^8.1
- nelmio/alice: ^3.7
- php-di/phpdoc-reader: ^2.2
Requires (Dev)
- richcongress/bundle-toolbox: ^2.0
- richcongress/static-analysis: ^0.2
- richcongress/test-tools: ^0.2
- roave/security-advisories: dev-latest
This package is auto-updated.
Last update: 2024-09-03 10:34:06 UTC
README
此库提供生成具有随机但有意义值的对象的工具。
目录
1. 快速展示
final class User { /** @var int */ private $id; /** @var string */ private $username; /** @var string */ private $password; /** @var \DateTime */ private $dateAdd; /** @var \DateTime */ private $dateUpdate; /** @var string */ private $biography; }
FixtureGenerator 可以创建此类的一个实例
$fixtureGenerator = new \RichCongress\FixtureTestBundle\Generator\FixtureGenerator(); $user = $fixtureGenerator->generate(User::class, [ 'biography' => 'This was generated by the library', ]);
如果我们以 Json 格式序列化该类,将会得到如下内容
{
// This is always null, we don't want the library to mess up with Doctrine
"id": null,
// This is a random username
"username": "john_doe",
// This is a random password
"password": "k&|X+a45*2[",
// This is a random date between -200 days and today
"dateAdd": "2019-12-03 11:07:02",
// Notice the dateUpdate is always after the dateAdd
"dateUpdate": "2020-03-04 18:57:41",
// This is a hard value given during the generation, so any property can be quickly overriden
"biography": "This was generated by the library"
}
2. 安装
本软件包需要 Symfony 6.0+ 和 PHP 8.1+。
composer require richcongress/fixture-test
2.1. Symfony
如果您打算与 Symfony 一起使用,请先安装 richcongress/bundle-toolbox,并确保 RichCongressFixtureTestBundle 在 bundles.php 中。
3. 文档
3.1. 配置
4. 版本控制
fixture-test 遵循 语义化版本控制。简而言之,该方案为 MAJOR.MINOR.PATCH,其中 1. MAJOR 在发生破坏性更改时增加,2. MINOR 在向后兼容的方式添加新功能时增加,3. PATCH 在向后兼容的方式修复错误时增加。
低于 1.0.0 的版本被视为实验性版本,可能随时发生破坏性更改。
5. 贡献
欢迎贡献力量!有很多种贡献方式,我们非常感激每一种。以下是一些主要方式:
-
错误报告:虽然我们努力提供高质量的软件,但错误仍然可能发生,我们不修复我们不知道的问题。因此,即使您不确定或只是想提问,也请报告。实际上,问题可能表明文档仍需改进!
-
功能请求:当前 API 没有涵盖您的用例?想建议更改或添加内容?我们将很高兴阅读并开始讨论以找到最佳解决方案。
-
Pull Request:想贡献代码或文档?我们将非常乐意!如果您需要帮助开始,GitHub 提供有关 Pull Request 的文档。我们使用 "fork and pull model",贡献者将更改推送到他们的个人分支,然后创建对主存储库的 pull request。请将您的 pull request 针对主分支
master。
作为提醒,所有贡献者都应遵守我们的 行为准则。
6. 许可证
cookies-regulation-bundle 根据 MIT 许可证分发。
有关详细信息,请参阅 LICENSE。
7. 破坏性修改
您可以使用 Docker 和 docker-compose 来修改项目。请查看以下命令。
# Start the project docker-compose up -d # Install dependencies docker-compose exec application composer install # Run tests docker-compose exec application bin/phpunit # Run a bash within the container docker-compose exec application bash