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, orHttpTestCase? Those live inez-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
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-16