rootwork / phpunit-helpers
PHPUnit Helpers
Installs: 3 783
Dependents: 3
Suggesters: 0
Security: 0
Stars: 1
Watchers: 4
Forks: 0
Open Issues: 0
Requires
- php: >=5.4
Requires (Dev)
- phpunit/phpunit: >=6.0
This package is auto-updated.
Last update: 2024-10-20 22:15:08 UTC
README
Helper traits for PHPUnit
"You can touch your privates and you can touch your friends' privates but you can't touch your parents' privates... unless they're protected." -Unknown
Installation
Install composer in a common location or in your project:
curl -s http://getcomposer.org/installer | php
Create the composer.json file as follows:
{ "require": { "rootwork/phpunit-helpers": "dev-master" } }
Run the composer installer:
php composer.phar install
Usage
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']); } }