aipng / test-helpers
Private properties trait useful for testing purposes
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-10-22 21:43:34 UTC
README
PrivatePropertyTrait
Provides an easy way to set private property of an object using reflection.
Do not use in production, use only for testing purposes.
Example: 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', ]); // ... } }