summaryrefslogtreecommitdiffstats
path: root/test/unit/TestUtils
diff options
context:
space:
mode:
authorJordan Nornhold <nornholdj@gmail.com>2015-10-10 10:10:24 -0400
committerJordan Nornhold <nornholdj@gmail.com>2015-10-10 10:10:24 -0400
commit7c39c1e35afb32845859289e8a0cd8eaceece5f2 (patch)
treea3b7e904158fe2145673a1d54676672096675a5f /test/unit/TestUtils
parentc2e4758d8df8cf7e20451ea3196f2dc918e245e1 (diff)
parent63022bf7bceb6aa7116159fd347be769594fa8b4 (diff)
downloadphp-sparkpost-7c39c1e35afb32845859289e8a0cd8eaceece5f2.zip
php-sparkpost-7c39c1e35afb32845859289e8a0cd8eaceece5f2.tar.gz
php-sparkpost-7c39c1e35afb32845859289e8a0cd8eaceece5f2.tar.bz2
Merge pull request #22 from SparkPost/http-adapter-update
Http adapter update
Diffstat (limited to 'test/unit/TestUtils')
-rw-r--r--test/unit/TestUtils/ClassUtils.php56
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);
+ }
+}
+?>