QRTestAbstract.php 1.3 KB

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