wikimedia/testing-access-wrapper
最新稳定版本:4.0.0
Composer 安装命令:
composer require wikimedia/testing-access-wrapper
包简介
A simple helper class to access non-public elements of a class when testing.
README 文档
README
Wikimedia Testing Access Wrapper
Testing Access Wrapper is a simple helper for writing unit tests which provides convenient shortcuts for using reflection to access non-public properties/methods.
The code was originally part of MediaWiki. See composer.json for a list of authors.
Usage
use Wikimedia\TestingAccessWrapper; class NonPublic { protected $prop; protected const CONSTANT = 4; protected function func() {} protected static function staticFunc() {} } class NonPublicCtor { protected function __construct() {} } $object = new NonPublic(); // or: // $object = TestingAccessWrapper::construct( NonPublicCtor::class ); $wrapper = TestingAccessWrapper::newFromObject( $object ); $classWrapper = TestingAccessWrapper::newFromClass( NonPublic::class ); $wrapper->prop = 'foo'; $wrapper->func(); $classWrapper->staticFunc(); $value = TestingAccessWrapper::constant( NonPublic::class, 'CONSTANT' );
Running tests
composer install
composer test
统计信息
- 总下载量: 1.88M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 1
- 依赖项目数: 13
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2017-04-19