kidfund / monkey-patcher
Get tricky with php objects in test
Installs: 1 947
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 2
Open Issues: 1
Requires
- php: ~7.0
Requires (Dev)
- phpunit/phpunit: ~7.0
This package is auto-updated.
Last update: 2024-11-11 15:52:51 UTC
README
Access private functions and properties of PHP classes. Primarily used to muck with things under test.
Install
Via Composer
$ composer require kidfund/monkey-patcher
Usage
Note: If you are using this, you may have a broken pattern somewhere. Either in your main code or in test-land. But, sometimes you need it!
Setup
Add the trait to your test
class MonkeyPatcherUnitTest extends PHPUnit_Framework_TestCase { use MonkeyPatcher;
Access a private function
$this->invokeMethod($object, 'do', ['something']);
Set a private property
$this->setProperty($object, 'msg', 'hello');
Get a private property
$this->getProperty($object, 'msg');
Testing
$ ./vendor/bin/phpunit
Contributing
Please see CONTRIBUTING and CONDUCT for details.
Credits
License
The MIT License (MIT). Please see License File for more information.