承接 ilmiont/trainline 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

ilmiont/trainline

Composer 安装命令:

composer require ilmiont/trainline

包简介

Trainline is a tiny PHP testing framework to enable the rapid creation of minimal unit tests.

README 文档

README

Trainline is a tiny PHP testing framework.

Getting started

Trainline requires PHP ^8.1.

composer require --dev ilmiont/trainline

Create a trainline.json file in your working directory:

{
	"directory": "tests/",
	"namespace": "Tests"
}

You can now run vendor/bin/trainline to execute your tests!

You can override any configuration key using CLI arguments: vendor/bin/trainline --directory tests/. When overridden in this way, every given CLI argument must be given a value.

Writing tests

Test units must be classes implementing Trainline\Framework\UnitInterface. It's recommended your tests extend Trainline\Framework\Unit which implements Trainline\Framework\UnitInterface.

Units must be constructable without any arguments. They must also be PSR-4 autoloadable within the directory and namespace roots you define in your configuration. Trainline automatically loads the vendor/autoload.php file in your working directory.

When extending Unit, all public methods in your class which are not prefixed with __ will be executed as test cases. Test cases receive no arguments and are not expected to return a value. Test cases are executed sequentially.

A successful test case is any which executes without throwing up.

__init() and __after()

The __init() method of your unit will be called before every test case.

The __after() method of your unit will be called after every test case.

__init() and __after() receive no arguments and are not expected to return a value.

__tests()

You can define which of your unit's methods should be executed as test cases by implementing this method. It must return an array of method names to execute as test cases.

Assertions

A basic set of assertion functions is included in the Trainline\Assertions namespace:

  • equiv(mixed $a, mixed $b) : bool - Checks $a == $b and throws a Trainline\Exceptions\AssertionException instance when this is not the case; the thrown exception when stringified contains pretty representations of the compared values.
  • ident(mixed $a, mixed $b) : bool - Checks $a === $b and throws a Trainline\Exceptions\AssertionException instance when this is not the case; the thrown exception when stringified contains pretty representations of the compared values.
  • throws(callable $callback, string $expect=null) - Invokes $callback and expects a Throwable to be thrown. Throws a Trainline\Exceptions\AssertionThrowsException when $callback executes without throwing. When $expect is given, the Throwable thrown by $callback must satisfy instanceof $expect; a Trainline\Exceptions\AssertionThrownException will be thrown when this is not the case, which emits pretty representations of the expected and received Throwable types when stringified. Returns the \Throwable thrown by $callback.

Reports

All output is currently emitted as formatted ANSI text to stdout.

ANSI compatibility is detected automatically. You can force ANSI output by setting the forceAnsi configuration key to true.

Test cases which encounter an error emit their name and the stringified representation of the Throwable which caused them to fail.

A summary containing test run statistics is emitted after all the test cases have been executed.

API

Trainline's internal API is not documented at this time.

You're welcome to examine the source to understand how extensions can be constructed.

©James Walker. Licensed under the MIT License.

ilmiont/trainline 适用场景与选型建议

ilmiont/trainline 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6.76k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 01 月 06 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 ilmiont/trainline 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 ilmiont/trainline 我们能提供哪些服务?
定制开发 / 二次开发

基于 ilmiont/trainline 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-01-06