reecem/mocker
Composer 安装命令:
composer require --dev reecem/mocker
包简介
Mock class constructor args based on the reflection class
README 文档
README
This package is initially made to for an issue on the MailEclipse package, but improvements are welcome. It currently is probably stupid simple, but deals with the one job of reading a file and mocking it.
Generate a mocked instance of the un-typed params in a __construct() method
This searches the file retrieved from the reflection class and looks for all object like arrow calls; ie:
... public function __construct($objectArg, string $arg) { $this->value = $objectArg->value; // this will be picked up $this->name = $arg; } ...
Installation
You can install the package via composer:
composer require reecem/mocker
Requirements
- Laravel ^5.6 (min)
Usage
use ReeceM\ReflectionMockery; /** * The class __construct Method is automatically read and args created */ $mock = new ReflectionMockery('\App\User'); // or $mock = new ReflectionMockery(new \ReflectionClass('\App\User')); // some time later /** * Use call a variable from the class that don't exist */ {{ $mock->get('somethingNotInUser') }} {{ $mock->somethingNotInUser }} // both would return "mock->somethingNotInUser" // if something was set in user 'mock->somethingNotInUser => ["value that set"]'
Security
If you discover any security related issues, please email zsh.rce@gmail.com instead of using the issue tracker.
Credits
todo
- Add functionality to account for
$this->internal = $param;searching so it works later on in the code - Add a translation file for mocked values when testing to give a translated result for previews
Support
Consider supporting some code if it is useful to you 😄
- MailEclipse "just a small donation from Laravel mail editor owner, thanks for your contributions"
License
The MIT License (MIT). Please see License File for more information.
Sponsors
|
reecem/mocker 适用场景与选型建议
reecem/mocker 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 261.15k 次下载、GitHub Stars 达 7, 最近一次更新时间为 2019 年 04 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「testing」 「mockery」 「helper」 「laravel」 「mocker」 「reecem」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 reecem/mocker 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 reecem/mocker 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 reecem/mocker 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Behat extension for mocking services defined in the Symfony2 dependency injection container.
Loads dependencies to mocked classes by Mockery for Nette Framework.
Testing Suite For Lumen like Laravel does.
WpBridge is a simple bridge to mock all wordpress function.
Datetime helpers for timezone handling
Shorthand for creating mock objects
统计信息
- 总下载量: 261.15k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 30
- 依赖项目数: 12
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-04-29