You are here

trait ProcessorTestTrait in Search API 8

Provides common methods for processor testing unit tests.

Hierarchy

File

tests/src/Unit/Processor/ProcessorTestTrait.php, line 8

Namespace

Drupal\Tests\search_api\Unit\Processor
View source
trait ProcessorTestTrait {

  /**
   * The tested processor.
   *
   * @var \Drupal\search_api\Processor\ProcessorInterface
   */
  protected $processor;

  /**
   * Invokes a method on the processor.
   *
   * @param string $method_name
   *   The method's name.
   * @param array $args
   *   (optional) The arguments to pass in the method call.
   *
   * @return mixed
   *   Whatever the invoked method returned.
   */
  protected function invokeMethod($method_name, array $args = []) {
    $class = new \ReflectionClass(get_class($this->processor));
    $method = $class
      ->getMethod($method_name);
    $method
      ->setAccessible(TRUE);
    return $method
      ->invokeArgs($this->processor, $args);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ProcessorTestTrait::$processor protected property The tested processor.
ProcessorTestTrait::invokeMethod protected function Invokes a method on the processor.