binarysolutions/test-data-blueprints
最新稳定版本:v0.1.1
Composer 安装命令:
composer require binarysolutions/test-data-blueprints
包简介
Laravel package for reusable scenario-based test datasets beyond factories and seeders.
README 文档
README
Reusable scenario-based test datasets for Laravel applications — built on top of factories, but designed to model full domain states.
What you get
- Fluent DSL:
Blueprint::define(...)->create(...)->tap(...) @reftoken resolution:@company,@company.id,@users[0].id- Composition:
->use('base-blueprint') - Snapshots:
->snapshot()+UsesBlueprintstrait caches datasets per test process (and params) - Time travel:
->at('2025-01-01')viaCarbon::setTestNow()(restored after run) - Artisan generator:
php artisan make:blueprint SaaSCompany
Install
composer require binarysolutions/test-data-blueprints --dev
Publish config (optional):
php artisan vendor:publish --tag=test-data-blueprints-config
Define a blueprint
Blueprint files are plain PHP in ./blueprints/*.php returning a Blueprint instance.
<?php use BinarySolutions\TestDataBlueprints\Fluent\Blueprint; use App\Models\Company; use App\Models\User; return Blueprint::define('saas-company') ->at('2025-01-01') ->create(Company::factory(), as: 'company') ->create(User::factory()->count(5)->for('@company'), as: 'users') ->snapshot();
Composition
return Blueprint::define('company-with-subscription') ->use('saas-company') ->create(Subscription::factory()->for('@company'), as: 'subscription') ->snapshot();
Use in PHPUnit
use BinarySolutions\TestDataBlueprints\Testing\UsesBlueprints; class MyTest extends TestCase { use UsesBlueprints; public function test_it_works() { $refs = $this->blueprint('saas-company', ['users' => 3]); $this->assertCount(3, $refs->get('users')); } }
Use in Pest
use BinarySolutions\TestDataBlueprints\Testing\UsesBlueprints; uses(UsesBlueprints::class)->in('Feature', 'Unit');
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-05-11