suin/php-expose

使非公开属性和方法可测试,以帮助您使用PHPUnit进行单元测试。

1.0 2012-09-16 08:57 UTC

This package is auto-updated.

Last update: 2024-09-06 08:30:50 UTC


README

Expose使非公开属性和方法可测试,以帮助您使用PHPUnit进行单元测试。

当前主分支的构建状态由Travis CI跟踪: 构建状态

<?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许可证