aipng / test-helpers
用于测试目的的私有属性特征
0.1
2018-11-22 09:01 UTC
Requires
- php: >= 7.1
Requires (Dev)
- phpstan/phpstan: ^0.10.5
- phpstan/phpstan-phpunit: ^0.10.0
- phpunit/phpunit: ^7.4
This package is auto-updated.
Last update: 2024-09-22 21:33:55 UTC
README
PrivatePropertyTrait
提供使用反射设置对象私有属性的一种简单方法。
请勿在生产环境中使用,仅用于测试目的。
示例:MyClass.php
final class MyClass { private $foo; // ... }
MyClassTest.php
final class MyClassTest extends TestCase { use PrivatePropertyTrait; public function testSetPrivateProperties(): void { $object = new MyClass; $this->setPrivateProperties($object, [ 'foo' => 'bar', ]); // ... } }