binarysolutions/test-data-blueprints 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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(...)
  • @ref token resolution: @company, @company.id, @users[0].id
  • Composition: ->use('base-blueprint')
  • Snapshots: ->snapshot() + UsesBlueprints trait caches datasets per test process (and params)
  • Time travel: ->at('2025-01-01') via Carbon::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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-05-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固