mirror of
				https://github.com/kevinveenbirkenbach/infinito.git
				synced 2025-11-03 18:58:01 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			29 lines
		
	
	
		
			881 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			881 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
namespace App\Tests;
 | 
						|
 | 
						|
use PHPUnit\Framework\TestCase;
 | 
						|
 | 
						|
abstract class AbstractTestCase extends TestCase
 | 
						|
{
 | 
						|
    /**
 | 
						|
     * Call protected/private method of a class.
 | 
						|
     *
 | 
						|
     * @see https://jtreminio.com/blog/unit-testing-tutorial-part-iii-testing-protected-private-methods-coverage-reports-and-crap/
 | 
						|
     *
 | 
						|
     * @param object &$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
 | 
						|
     *
 | 
						|
     * @return mixed method return
 | 
						|
     */
 | 
						|
    public function invokeMethod(&$object, $methodName, array $parameters = [])
 | 
						|
    {
 | 
						|
        $reflection = new \ReflectionClass(get_class($object));
 | 
						|
        $method = $reflection->getMethod($methodName);
 | 
						|
        $method->setAccessible(true);
 | 
						|
 | 
						|
        return $method->invokeArgs($object, $parameters);
 | 
						|
    }
 | 
						|
}
 |