stratedge/wye
Composer 安装命令:
composer require --dev stratedge/wye
包简介
A library that makes unit testing database-driven code in PHP a breeze. Mock the native PDO class, define query results, and inspect executed statements.
关键字:
README 文档
README
A library that makes unit testing database-driven code in PHP a breeze. Mock the native PDO class, define query results, and inspect executed statements.
"[In firefighting a] hose appliance used for splitting one line into two discharges. Often a gated wye is used to allow and disallow water flow through the two separate discharges." - https://en.wikipedia.org/wiki/Glossary_of_firefighting_equipment#Wye
Installation
Wye is registered with Packagist and can be installed with Composer. Run the following on the command line:
composer require --dev stratedge/wye
Once Wye has been included in your project, just make sure to require Composer's autoloader:
require_once 'vendor/autoload.php';
Basic Usage Example
use Stratedge\Wye\Wye; //In test setup //------------- //Reset the Wye to its clean state Wye::reset() //Create a Wye PDO object $pdo = Wye::makePDO(); //Inject PDO into database layer Database::setConnection($pdo); //In test //------- //Create a Result object $result = Wye::makeResult(); //Add a row or two to return $result->addRow(['type' => 'Pumper', 'apparatus' => 'Engine 1']); //Attach Result to Wye to be served when a query is executed $result->attach(); //Run code to test $class_to_test->doSomething(); //Inspect execution $stmt = Wye::getStatementAtIndex(0); $this->assertStringStartsWith('SELECT', $stmt->getStatement()); $this->assertCount(2, count($stmt->getBindings()); $this->assertSame('id', $stmt->getBindings()->first()->getParameter()); $this->assertSame(1, Wye::getNumQueries()); //and more!
WAIT, THERE'S MORE
For a much more in-depth look at Wye's usage, check out the extensive documentation, especially the section on Basic Usage.
Documentation
Complete and up-to-date documentation is available on the Wiki.
Some of the major topics discussed include: An Introduction, Defining Results, Inspecting Execution Info, and Inspecting Bindings.
Todo & Roadmap
List of enhancements and implementations is available on the Todo & Roadmap page of the wiki.
Issue Tracking
If you should find an issue in Wye, and you think you can fix it, by all means please do so. Pull requests are gladly accepted. If you don't have the time or energy to fix it, please log the issue with as much detail as possible so I can take a look.
Issues can be logged on the Github issue tracker.
Acknowledgements
Wye is built on top of an idea I first saw implemented by my friend/colleague Josh.
stratedge/wye 适用场景与选型建议
stratedge/wye 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5.29k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2017 年 04 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「database」 「testing」 「phpunit」 「mysql」 「test」 「mock」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 stratedge/wye 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 stratedge/wye 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 stratedge/wye 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Dibi is Database Abstraction Library for PHP
HiDev plugin for PHPUnit
Testing Suite For Lumen like Laravel does.
A cli tool which generates unit tests.
Store your language lines in the database, yaml or other sources
A package for automatically encrypting and decrypting Eloquent attributes in Laravel 5.5+, based on configuration settings.
统计信息
- 总下载量: 5.29k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 22
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-04-23