testing-access-wrapper
Simple unit test helper for accessing non-public properties/methods.
 All Classes Functions
testing-access-wrapper Documentation

![Latest Stable Version] ![License]

Wikimedia Testing Access Wrapper

Testing Access Wrapper is a simple helper for writing unit tests which provides convenient shortcuts for using reflection to access non-public properties/methods.

The code was originally part of MediaWiki. See composer.json for a list of authors.

Usage

use Wikimedia;
class NonPublic {
    protected $prop;
    protected function func() {}
    protected static function staticFunc() {}
}
$object = new NonPublic();
$wrapper = TestingAccessWrapper::newFromObject( $object );
$classWrapper = TestingAccessWrapper::newFromClass( NonPublic::class );
$wrapper->prop = 'foo';
$wrapper->func();
$classWrapper->staticFunc();

Running tests

composer install
composer test