jorj-sh/php-test-quality
Composer 安装命令:
composer create-project jorj-sh/php-test-quality
包简介
AST-based test quality analyser for PHPUnit tests
README 文档
README
AST-based test quality analyser for PHPUnit tests. Detects common test smells by parsing PHP test files and walking the abstract syntax tree.
Requirements
- PHP >= 8.4
Installation
PHAR (no Composer needed):
curl -L https://github.com/jorjives/php-test-quality/releases/latest/download/tq.phar -o tq.phar chmod +x tq.phar php tq.phar path/to/tests/
Docker (no PHP needed):
docker run --rm -v $(pwd):/code ghcr.io/jorjives/php-test-quality /code/tests/
Composer global:
composer global require jorj-sh/php-test-quality tq path/to/tests/
Composer dev dependency:
composer require --dev jorj-sh/php-test-quality vendor/bin/tq path/to/tests/
Usage
# Analyse a test directory tq path/to/tests/ # JSON output tq path/to/tests/ --format=json # Run only specific detectors tq path/to/tests/ --only=no_assertions,assertion_roulette # List available detectors tq list-types # Generate a baseline (requires --reason) tq path/to/tests/ --generate-baseline --baseline=.tq-baseline.json --reason="Initial baseline" # Filter using a baseline tq path/to/tests/ --baseline=.tq-baseline.json
Configuration
tq auto-detects a .tq.yaml file in the scan directory. Override with --config=path/to/.tq.yaml or skip entirely with --no-config. CLI flags always take precedence over config values.
thresholds: long_test: 40 magic_number_allowlist: # replaces default list entirely - 0 - 1 - 200 - 404 magic_number_allowlist_extra: # appends to active list - 42 detectors: enabled: all disabled: - conditional_test_logic baseline: .tq-baseline.json
Detectors
| Type | Name | Description |
|---|---|---|
no_assertions |
Assertion Count | Tests with no assertions |
assertion_roulette |
Assertion Roulette | Multiple assertions without descriptive messages |
constructor_initialization |
Constructor Initialization | Test classes using __construct() instead of setUp() |
empty_test |
Empty Test | Test methods with no executable statements |
sleepy_test |
Sleepy Test | Tests using sleep()/usleep() |
redundant_print |
Redundant Print | Debug output (var_dump, echo, etc.) in tests |
exception_handling |
Exception Handling | Try-catch blocks instead of expectException() |
interface_testing |
Interface Testing Anti-Patterns | Mock-only interface testing |
conditional_test_logic |
Conditional Test Logic | if/switch/ternary in tests |
magic_number_test |
Magic Number Test | Non-trivial numeric literals in assertions |
redundant_assertion |
Redundant Assertion | Tautological assertions like assertEquals(1, 1) |
rotten_green_test |
Rotten Green Test | Assertions inside conditionals or after return/throw |
mystery_guest |
Mystery Guest | File I/O or database calls in test bodies |
long_test |
Long Test | Tests exceeding 40 lines |
Docker
# Use the published image docker run --rm -v $(pwd):/code ghcr.io/jorjives/php-test-quality /code/tests/ # Or build locally docker build -t php-test-quality . docker run --rm -v /path/to/tests:/tests php-test-quality /tests
Licence
MIT
jorj-sh/php-test-quality 适用场景与选型建议
jorj-sh/php-test-quality 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 jorj-sh/php-test-quality 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jorj-sh/php-test-quality 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 29
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-24