QRTestAbstract.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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, ReflectionMethod, ReflectionProperty;
  15. abstract class QRTestAbstract extends TestCase{
  16. protected ReflectionClass $reflection;
  17. protected string $FQCN;
  18. protected function setUp():void{
  19. $this->reflection = new ReflectionClass($this->FQCN);
  20. }
  21. /**
  22. * @param string $method
  23. *
  24. * @return \ReflectionMethod
  25. */
  26. protected function getMethod(string $method):ReflectionMethod {
  27. $method = $this->reflection->getMethod($method);
  28. $method->setAccessible(true);
  29. return $method;
  30. }
  31. /**
  32. * @param string $property
  33. *
  34. * @return \ReflectionProperty
  35. */
  36. protected function getProperty(string $property):ReflectionProperty{
  37. $property = $this->reflection->getProperty($property);
  38. $property->setAccessible(true);
  39. return $property;
  40. }
  41. /**
  42. * @param $object
  43. * @param string $property
  44. * @param $value
  45. *
  46. * @return void
  47. */
  48. protected function setProperty($object, string $property, $value){
  49. $property = $this->getProperty($property);
  50. $property->setAccessible(true);
  51. $property->setValue($object, $value);
  52. }
  53. }