diff options
author | Arnold Daniels <arnold@jasny.net> | 2017-01-26 11:35:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-26 11:35:16 +0100 |
commit | 51c88bded1a907b19e44344de35871822ba95829 (patch) | |
tree | afa90e7d24ebe2d7eadb87945fd3f07c66afdb15 /tests/support | |
parent | 9701118b9b34e19d5de1fe56755afdd29c0c93a1 (diff) | |
parent | 36cece638bb83b9755eee620d5132893aa969b28 (diff) | |
download | controller-1.1.0.zip controller-1.1.0.tar.gz controller-1.1.0.tar.bz2 |
Merge pull request #12 from Minstel/11-Add_content_negotiationv1.1.0
Add content negotiation (fixes #11)
Diffstat (limited to 'tests/support')
-rw-r--r-- | tests/support/TestHelper.php | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/tests/support/TestHelper.php b/tests/support/TestHelper.php index a046e4e..05b40d7 100644 --- a/tests/support/TestHelper.php +++ b/tests/support/TestHelper.php @@ -20,14 +20,14 @@ trait TestHelper /** * Get the controller class - * + * * @return string */ protected function getControllerClass() { return Controller::class; } - + /** * Get mock for controller * @@ -46,14 +46,14 @@ trait TestHelper if (isset($mockClassName)) { $builder->setMockClassName($mockClassName); } - + $getMock = trait_exists($class) ? 'getMockForTrait' : 'getMockForAbstractClass'; return $builder->$getMock(); } - + /** * Set a private or protected property of the given object - * + * * @param object $object * @param string $property * @param mixed $value @@ -63,9 +63,26 @@ trait TestHelper if (!is_object($object)) { throw new \InvalidArgumentException("Excpected an object, got a " . gettype($object)); } - + $refl = new \ReflectionProperty($object, $property); $refl->setAccessible(true); $refl->setValue($object, $value); } + + /** + * Call protected method on some object + * + * @param object $object + * @param string $name Method name + * @param array $args + * @return mixed Result of method call + */ + protected function callProtectedMethod($object, $name, $args) + { + $class = new \ReflectionClass($object); + $method = $class->getMethod($name); + $method->setAccessible(true); + + return $method->invokeArgs($object, $args); + } } |