定制 ez-php/testing 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

ez-php/testing

Composer 安装命令:

composer require --dev ez-php/testing

包简介

Test utilities for the ez-php framework — ApplicationTestCase, DatabaseTestCase, HttpTestCase, ModelFactory

README 文档

README

Framework-independent test utilities for ez-php — response assertions and an entity factory.

Looking for ApplicationTestCase, DatabaseTestCase, or HttpTestCase? Those live in ez-php/testing-application, which boots the full framework stack.

Requirements

  • PHP 8.5+
  • PHPUnit 13+
  • ez-php/http
  • ez-php/orm

Installation

composer require --dev ez-php/testing

Classes

TestResponse

Wraps a Response with a fluent PHPUnit assertion API. Returned by HttpTestCase helpers in ez-php/testing-application.

Method Description
assertStatus(int) Exact status code
assertOk() Status 200
assertNotFound() Status 404
assertRedirect(?string) 3xx; optional Location header
assertSee(string) Body contains substring
assertJson(array) Body decodes to exact array
assertHeader(string, ?string) Header present; optional value

EntityFactory

Builds and optionally persists Entity instances with default attributes. Callable defaults are invoked once per instance. Persistence is delegated to an AbstractRepository.

use EzPhp\Testing\EntityFactory;

$factory = new EntityFactory(User::class, $userRepo, [
    'name'  => 'Alice',
    'email' => fn () => uniqid('user_') . '@example.com',
]);

$user  = $factory->make();             // not persisted
$user  = $factory->create();           // persisted via $userRepo->save()
$users = $factory->makeMany(3);
$users = $factory->createMany(5, ['role' => 'admin']);

Setup (standalone development)

cp .env.example .env
./start.sh

统计信息

  • 总下载量: 3.4k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固