PHP code example of gollumsf / reflection-property-test
1. Go to this page and download the library: Download gollumsf/reflection-property-test library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
gollumsf / reflection-property-test example snippets
use GollumSF\ReflectionPropertyTest\ReflectionPropertyTrait;
class MyPrivate {
private $dataPrivate = 10;
private function functionPrivate($value) {
return 11 + $value;
}
}
class MyExtend extends MyPrivate {
}
class MyTest extends TestCase {
use ReflectionPropertyTrait;
testMyFunction() {
$obj = new MyPrivate();
$this->assertEqual($this->reflectionGetValue($obj, 'reflectionGetValue'), 10);
$this->reflectionSetValue($obj, 'reflectionGetValue', 20);
$this->assertEqual($this->reflectionGetValue($obj, 'reflectionGetValue'), 20);
$this->assertEqual($this->reflectionGetValue($obj, 'functionPrivate', [ 19 ]), 30);
$obj2 = new MyExtend();
$this->assertEqual($this->reflectionGetValue($obj2, 'reflectionGetValue', MyPrivate::class), 10);
$this->reflectionSetValue($obj2, 'reflectionGetValue', 20, MyPrivate::class);
$this->assertEqual($this->reflectionGetValue($obj2, 'reflectionGetValue', MyPrivate::class), 20);
$this->assertEqual($this->reflectionGetValue($obj2, 'functionPrivate', [ 19 ], MyPrivate::class), 30);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.