diff options
author | beardyman <nornholdj@gmail.com> | 2015-10-10 10:18:55 -0400 |
---|---|---|
committer | beardyman <nornholdj@gmail.com> | 2015-10-10 10:18:55 -0400 |
commit | 20301cd311307b8357459a299c3c9746ecf8c065 (patch) | |
tree | 7c0bef42eb7e25f90eebf04e1bd8b91f9ce9e5da /test/unit/TestUtils/ClassUtils.php | |
parent | 4b8a1370698581fece4d5ec188851031e41dcad0 (diff) | |
parent | 7c39c1e35afb32845859289e8a0cd8eaceece5f2 (diff) | |
download | php-sparkpost-20301cd311307b8357459a299c3c9746ecf8c065.zip php-sparkpost-20301cd311307b8357459a299c3c9746ecf8c065.tar.gz php-sparkpost-20301cd311307b8357459a299c3c9746ecf8c065.tar.bz2 |
Merged master
Diffstat (limited to 'test/unit/TestUtils/ClassUtils.php')
-rw-r--r-- | test/unit/TestUtils/ClassUtils.php | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/test/unit/TestUtils/ClassUtils.php b/test/unit/TestUtils/ClassUtils.php new file mode 100644 index 0000000..26d264c --- /dev/null +++ b/test/unit/TestUtils/ClassUtils.php @@ -0,0 +1,56 @@ +<?php +namespace SparkPost\Test\TestUtils; + + +class ClassUtils { + + private $class; + + public function __construct($fqClassName) { + $this->class = new \ReflectionClass($fqClassName); + } + + /** + * Allows access to private methods + * + * This is needed to mock the GuzzleHttp\Client responses + * + * @param string $name + * @return ReflectionMethod + */ + public function getMethod($method) { + $method = $this->class->getMethod($name); + $method->setAccessible(true); + return $method; + } + + /** + * Allows access to private properties in the Transmission class + * + * This is needed to mock the GuzzleHttp\Client responses + * + * @param string $name + * @param {*} + * @return ReflectionMethod + */ + public function getProperty($instance, $property) { + $prop = $this->class->getProperty($property); + $prop->setAccessible(true); + return $prop->getValue($instance); + } + /** + * Allows access to private properties in the Transmission class + * + * This is needed to mock the GuzzleHttp\Client responses + * + * @param string $name + * @param {*} + * @return ReflectionMethod + */ + public function setProperty($instance, $property, $value) { + $prop = $this->class->getProperty($property); + $prop->setAccessible(true); + $prop->setValue($instance, $value); + } +} +?> |