blob: 7b9eb80492ee2e1c2643d117b876e7383bd21c93 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
<?php
/**
* Class QRTestAbstract
*
* @filesource QRTestAbstract.php
* @created 17.11.2017
* @package chillerlan\QRCodeTest
* @author Smiley <[email protected]>
* @copyright 2017 Smiley
* @license MIT
*/
namespace chillerlan\QRCodeTest;
use PHPUnit\Framework\TestCase;
use ReflectionClass, ReflectionMethod, ReflectionProperty;
abstract class QRTestAbstract extends TestCase{
/**
* @var \ReflectionClass
*/
protected $reflection;
/**
* @var string
*/
protected $FQCN;
protected function setUp():void{
$this->reflection = new ReflectionClass($this->FQCN);
}
/**
* @param string $method
*
* @return \ReflectionMethod
*/
protected function getMethod(string $method):ReflectionMethod {
$method = $this->reflection->getMethod($method);
$method->setAccessible(true);
return $method;
}
/**
* @param string $property
*
* @return \ReflectionProperty
*/
protected function getProperty(string $property):ReflectionProperty{
$property = $this->reflection->getProperty($property);
$property->setAccessible(true);
return $property;
}
/**
* @param $object
* @param string $property
* @param $value
*
* @return void
*/
protected function setProperty($object, string $property, $value){
$property = $this->getProperty($property);
$property->setAccessible(true);
$property->setValue($object, $value);
}
}
|