mirror of
				https://github.com/kevinveenbirkenbach/infinito.git
				synced 2025-11-04 03:07:58 +00:00 
			
		
		
		
	finished implementation of members attribute and test
This commit is contained in:
		@@ -1,4 +1,5 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace App\Tests;
 | 
			
		||||
 | 
			
		||||
use PHPUnit\Framework\TestCase;
 | 
			
		||||
@@ -7,20 +8,21 @@ 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 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.
 | 
			
		||||
     * @param array  $parameters array of parameters to pass into method
 | 
			
		||||
     *
 | 
			
		||||
     * @return mixed Method return.
 | 
			
		||||
     * @return mixed method return
 | 
			
		||||
     */
 | 
			
		||||
    public function invokeMethod(&$object, $methodName, array $parameters = array())
 | 
			
		||||
    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);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user