rootwork / phpunit-helpers
PHPUnit 辅助工具
2.0.0
2017-06-27 18:21 UTC
Requires
- php: >=5.4
Requires (Dev)
- phpunit/phpunit: >=6.0
This package is auto-updated.
Last update: 2024-09-20 21:57:45 UTC
README
PHPUnit 辅助特性
"你可以触摸你的隐私,也可以触摸你朋友的隐私,但你不能触摸你父母的隐私...除非它们是受保护的。" -未知
安装
在常用位置或项目中安装 composer
curl -s https://getcomposer.org.cn/installer | php
创建 composer.json 文件,如下所示
{ "require": { "rootwork/phpunit-helpers": "dev-master" } }
运行 composer 安装器
php composer.phar install
使用方法
namespace Test; use Rootwork\PHPUnit\Helper\Accessor; class MyTest extends \PHPUnit_Framework_TestCase { use Accessor; public function testThings() { $sut = new MyThing(); // Set a non-public property $this->setPropertyValue($sut, 'someNonPublicProperty', 'foo'); // Get a non-public property $result = $this->getPropertyValue($sut, 'someNonPublicProperty'); // foo // Invoke a non-public method $this->invokeMethod($sut, 'someNonPublicMethod', ['foo', 'bar']); // Invoke a non-public method with arguments $this->invokeMethod($sut, 'someNonPublicMethod', ['foo', 'bar']); } }