Skip to content

Commit

Permalink
TestFramework: extended reflection helper
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Gladysch committed Apr 5, 2016
1 parent 6514d24 commit 106e5f3
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/glady/Behind/TestFramework/UnitTest/Helper/Reflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,24 @@
*/
class Reflection
{

/**
* @param $className
* @param string|object $class
* @return ReflectionClass
*/
public function getClass($className)
public function getClass($class)
{
return new ReflectionClass($className);
return new ReflectionClass($class);
}


/**
* @param $className
* @param $methodName
* @param string|object $class
* @param string $methodName
* @return ReflectionMethod
*/
public function getMethod($className, $methodName)
public function getMethod($class, $methodName)
{
$method = $this->getClass($className)->getMethod($methodName);
$method = $this->getClass($class)->getMethod($methodName);
$method->setAccessible(true);
return $method;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
/*
* This file is part of the Behind-Project (https://github.com/glady/Behind).
*
* (c) Mike Gladysch <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace glady\Behind\src\glady\Behind\TestFramework\UnitTest\Helper;

use glady\Behind\TestFramework\UnitTest\Helper\Reflection;

/**
* Class ReflectionWrapper
* @package glady\Behind\src\glady\Behind\TestFramework\UnitTest\Helper
*/
class ReflectionWrapper
{
/**
* @param object $object
*/
public function __construct($object)
{
$this->original = $object;
$this->reflection = new Reflection();
}


/**
* @param string $name
* @param array $arguments
* @return mixed
*/
public function __call($name, $arguments)
{
$method = $this->reflection->getMethod($this->original, $name);
return $method->invokeArgs($this->original, $arguments);
}
}

0 comments on commit 106e5f3

Please sign in to comment.