]> scripts.mit.edu Git - autoinstalls/mediawiki.git/blob - vendor/wikimedia/testing-access-wrapper/README.md
MediaWiki 1.30.2
[autoinstalls/mediawiki.git] / vendor / wikimedia / testing-access-wrapper / README.md
1 [![Latest Stable Version]](https://packagist.org/packages/wikimedia/testing-access-wrapper) [![License]](https://packagist.org/packages/wikimedia/testing-access-wrapper)
2
3 Wikimedia Testing Access Wrapper
4 ================================
5
6 Testing Access Wrapper is a simple helper for writing unit tests which provides
7 convenient shortcuts for using reflection to access non-public properties/methods.
8
9 The code was originally part of MediaWiki. See composer.json for a list of authors.
10
11 Usage
12 -----
13
14 ```php
15 use Wikimedia\TestingAccessWrapper;
16
17 class NonPublic {
18         protected $prop;
19         protected function func() {}
20         protected static function staticFunc() {}
21 }
22
23 $object = new NonPublic();
24 $wrapper = TestingAccessWrapper::newFromObject( $object );
25 $classWrapper = TestingAccessWrapper::newFromClass( NonPublic::class );
26
27 $wrapper->prop = 'foo';
28 $wrapper->func();
29 $classWrapper->staticFunc();
30 ```
31
32 Running tests
33 -------------
34
35     composer install
36     composer test
37
38
39 ---
40 [Latest Stable Version]: https://poser.pugx.org/wikimedia/testing-access-wrapper/v/stable.svg
41 [License]: https://poser.pugx.org/wikimedia/testing-access-wrapper/license.svg