forked from crschoen/FlexibleMink
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestCase.php
30 lines (26 loc) · 908 Bytes
/
TestCase.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
namespace Tests;
use PHPUnit_Framework_TestCase;
use ReflectionClass;
use ReflectionException;
class TestCase extends PHPUnit_Framework_TestCase
{
/**
* Call protected/private method of a class.
*
* @param object|string $object Instantiated object that we will run method on
* @param string $methodName Method name to call
* @param array $parameters array of parameters to pass into method
*
* @throws ReflectionException if there is a problem invoking the method
*
* @return mixed method return
*/
public function invokeMethod($object, $methodName, array $parameters = [])
{
$reflection = new ReflectionClass($object);
$method = $reflection->getMethod($methodName);
$method->setAccessible(true);
return $method->invokeArgs((is_string($object) ? null : $object), $parameters);
}
}