protected static function MockHelperTrait::callProtectedMethod in Mini site 8
Call protected methods on the class.
Parameters
object|string $object: Object or class name to use for a method call.
string $method: Method name. Method can be static.
array $args: Array of arguments to pass to the method. To pass arguments by reference, pass them by reference as an element of this array.
Return value
mixed Method result.
3 calls to MockHelperTrait::callProtectedMethod()
- UrlBagTest::testGetUriPart in tests/
src/ Kernel/ UrlBagTest.php - Tests getUriPart() method.
- UrlBagTest::testToAbsolute in tests/
src/ Kernel/ UrlBagTest.php - Tests toAbsolute() method.
- UrlBagTest::testToLocal in tests/
src/ Kernel/ UrlBagTest.php - Tests toLocal() method.
File
- tests/
src/ Traits/ MockHelperTrait.php, line 28
Class
- MockHelperTrait
- Trait MockHelperTrait.
Namespace
Drupal\Tests\minisite\TraitsCode
protected static function callProtectedMethod($object, $method, array $args = []) {
$class = new \ReflectionClass(is_object($object) ? get_class($object) : $object);
$method = $class
->getMethod($method);
$method
->setAccessible(TRUE);
$object = $method
->isStatic() ? NULL : $object;
return $method
->invokeArgs($object, $args);
}