voltel / extra-foundry-bundle
通过延迟持久化和聚合刷新,增加功能使 zenstruck/foundry 运行更快
v1.3.0
2021-04-29 07:53 UTC
Requires
- php: ^7.4
- fakerphp/faker: ^1.13
- symfony/config: ^5.1
- symfony/dependency-injection: ^5.1
- symfony/http-kernel: ^5.1
- symfony/orm-pack: ^2.1
- zenstruck/foundry: ^1.10.0
Requires (Dev)
- ext-simplexml: *
- symfony/browser-kit: ^5.2
- symfony/framework-bundle: 5.2
- symfony/phpunit-bridge: ^5.2
This package is auto-updated.
Last update: 2024-08-29 05:44:01 UTC
README
此包是 zenstruck/foundry 包的包装器。
它具有以下功能
- 延迟持久化 以节省开发数据库播种时间;
- MySQL 转储文件加载器 用于在 "测试" 环境中重新创建初始数据库状态并最小化测试时间;
- 一个设置服务,用于从 蓝图 中创建实体,这是在测试(例如,与数据提供者一起使用)或 "dev" 环境中播种数据库时使用的方便工具;
- 在 zenstruck/foundry 执行操作的方式上进行了多项 "改进"。
文档
在 https://voltelextrafoundrybundle.readthedocs.io/en/latest/ 读取文档。
文档的源文件位于包的 "docs/" 文件夹中,以 reStructuredText 格式文件 (*.rst) 存储。
使用方法
有关使用示例,请 阅读文档 并查看测试套件中的源代码(在包的 "test/Setup" 目录中)。
播种开发数据库
$order_entity = $this->persistService->createOne($factory_order, ['customer' => $customer_entity], ['sent'] ); $order_item_batch = $this->persistService->createMany($factory_order_item, rand(1, 4), function() { return [ 'unitCount' => rand(1, 20) ]; });
从 蓝图 中创建实体
$a_setup_customers = [ 'customer_1' =>['states' => ['american', 'human']], 'customer_2' =>['states' => ['ukrainian', 'human'], 'customer_3' =>['states' => ['human'], 'attributes' => ['firstName' => 'John', 'lastName' => 'Doe']], 'customer_4' =>['states' => ['human'], 'attributes' => ['firstName' => 'Богдан', 'lastName' => 'Мірошник']], ]; $this->setUpFixtureEntityService-> createEntities($factory_customer, $a_setup_customers, true);
从 MySQL 转储文件加载全局状态
class GlobalStory extends Story { //... public function build(): void { $this->sqlDumpLoaderService->loadSqlDump(); } }
您可以在文档中以及在包的 "tests/" 目录中找到更多 示例。
贡献
Of course, open source is fueled by everyone's ability to give just a little bit
of their time for the greater good. If you'd like to see a feature or add some of
your *own* happy words, awesome! You can request it - but creating a pull request
is an even better way to get things done.
Either way, please feel comfortable submitting issues or pull requests: all contributions
and questions are warmly appreciated :).
话虽如此,您可能会觉得为 zenstruck/foundry 项目本身做出贡献 更加合适,因为这个包只是一个方便的包装器。