You are here

public function EntityManagerTest::invokeMethod in Acquia Content Hub 8

Call protected/private method of a class.

Parameters

object &$object: Instantiated object that we will run method on.

string $methodName: Method name to call.

array $parameters: Array of parameters to pass into method.

Return value

mixed Method return.

File

tests/src/Unit/EntityManagerTest.php, line 134

Class

EntityManagerTest
PHPUnit for the EntityManager class.

Namespace

Drupal\Tests\acquia_contenthub\Unit

Code

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);
}