protected function InvokeMethodTrait::invokeMethod in Commerce Google Tag Manager 8
Same name and namespace in other branches
- 8.2 tests/src/Traits/InvokeMethodTrait.php \Drupal\Tests\commerce_google_tag_manager\Traits\InvokeMethodTrait::invokeMethod()
Calls protected/private method of a class.
Parameters
object &$object: Instantiated object that we will run method on.
string $method_name: Method name to call.
array $parameters: Array of parameters to pass into method.
array $protected_properties: Array of values that should be set on protected properties.
Return value
mixed Method return.
10 calls to InvokeMethodTrait::invokeMethod()
- EventStorageServiceTest::testHash in tests/
src/ Unit/ EventStorageServiceTest.php - @covers ::hash
- EventTrackerServicePurchaseTest::testPurchaseOrder in tests/
src/ Kernel/ EventTrackerServicePurchaseTest.php - @covers ::purchase
- EventTrackerServicePurchaseTest::testPurchaseOrderTaxExemptPrices in tests/
src/ Kernel/ EventTrackerServicePurchaseTest.php - @covers ::purchase
- EventTrackerServicePurchaseTest::testPurchaseOrderWithTaxExclusiveOnOrder in tests/
src/ Kernel/ EventTrackerServicePurchaseTest.php - @covers ::purchase
- EventTrackerServicePurchaseTest::testPurchaseOrderWithTaxExclusiveOnOrderItems in tests/
src/ Kernel/ EventTrackerServicePurchaseTest.php - @covers ::purchase
File
- tests/
src/ Traits/ InvokeMethodTrait.php, line 25
Class
- InvokeMethodTrait
- Provides a function to invoke protected/private methods of a class.
Namespace
Drupal\Tests\commerce_google_tag_manager\TraitsCode
protected function invokeMethod(&$object, $method_name, array $parameters = [], array $protected_properties = []) {
$reflection = new \ReflectionClass(get_class($object));
foreach ($protected_properties as $property => $value) {
$property = $reflection
->getProperty($property);
$property
->setAccessible(TRUE);
$property
->setValue($object, $value);
}
$method = $reflection
->getMethod($method_name);
$method
->setAccessible(TRUE);
return $method
->invokeArgs($object, $parameters);
}