protected function InvokeMethodTrait::invokeMethod in Search API Solr 8.2
Same name and namespace in other branches
- 8.3 tests/src/Traits/InvokeMethodTrait.php \Drupal\Tests\search_api_solr\Traits\InvokeMethodTrait::invokeMethod()
- 8 tests/src/Traits/InvokeMethodTrait.php \Drupal\Tests\search_api_solr\Traits\InvokeMethodTrait::invokeMethod()
- 4.x tests/src/Traits/InvokeMethodTrait.php \Drupal\Tests\search_api_solr\Traits\InvokeMethodTrait::invokeMethod()
Calls protected/private method of a class.
Parameters
object &$object: Instantiated object that we will run method on.
string: Method name to call.
array $parameters: Array of parameters to pass into method.
array $protectedProperties: Array of values that should be set on protected properties.
Return value
mixed Method return.
10 calls to InvokeMethodTrait::invokeMethod()
- SearchApiBackendUnitTest::testIndexField in tests/
src/ Unit/ SearchApiBackendUnitTest.php - @covers ::addIndexField
- SearchApiSolrMultilingualTest::testQueryConditionsAndLanguageFilter in tests/
src/ Kernel/ SearchApiSolrMultilingualTest.php - Tests the conversion of language aware queries into Solr queries.
- SearchApiSolrTest::getFieldsAndMapping in tests/
src/ Kernel/ SearchApiSolrTest.php - Gets the Drupal Fields and their Solr mapping.
- SearchApiSolrTest::indexPrefixTest in tests/
src/ Kernel/ SearchApiSolrTest.php - SearchApiSolrTest::regressionTest2850160 in tests/
src/ Kernel/ SearchApiSolrTest.php - Regression tests for #2850160.
File
- tests/
src/ Traits/ InvokeMethodTrait.php, line 25
Class
- InvokeMethodTrait
- Provides a function to invoke protected/private methods of a class.
Namespace
Drupal\Tests\search_api_solr\TraitsCode
protected function invokeMethod(&$object, $methodName, array $parameters = [], array $protectedProperties = []) {
$reflection = new \ReflectionClass(get_class($object));
foreach ($protectedProperties as $property => $value) {
$property = $reflection
->getProperty($property);
$property
->setAccessible(true);
$property
->setValue($object, $value);
}
$method = $reflection
->getMethod($methodName);
$method
->setAccessible(TRUE);
return $method
->invokeArgs($object, $parameters);
}