suin / php-expose
使非公开属性和方法可测试,以帮助您使用PHPUnit进行单元测试。
1.0
2012-09-16 08:57 UTC
Requires
- php: >=5.3.0
This package is auto-updated.
Last update: 2024-09-06 08:30:50 UTC
README
Expose
使非公开属性和方法可测试,以帮助您使用PHPUnit进行单元测试。
<?php use \Expose\Expose as e; class Object { private $_secret; protected $_protected; private function _hello($world = 'World') { return sprintf('Hello, %s', $world); } } $object = new Object(); // Expose non-public properties e::expose($object) ->attr('_secret', 'foo') ->attr('_protected', 'bar'); // Call non-public method $result = e::expose($object)->call('_hello', 'Suin');
要求
- PHP 5.3或更高版本
安装
只需git-clone或通过composer安装。
composer.json
{ "require": { "suin/php-expose": ">=1.0" } }
在PHPUnit的bootstrap.php
中包含vendor/autoload.php
以加载Expose
组件
require_once 'vendor/autoload.php';
许可证
MIT许可证