You are here

class StubReflectionFactory in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Component/Plugin/Factory/ReflectionFactoryTest.php \Drupal\Tests\Component\Plugin\Factory\StubReflectionFactory
  2. 9 core/tests/Drupal/Tests/Component/Plugin/Factory/ReflectionFactoryTest.php \Drupal\Tests\Component\Plugin\Factory\StubReflectionFactory

Override ReflectionFactory because ::createInstance() calls a static method.

We have to override getPluginClass so that we can stub out its return value.

Hierarchy

  • class \Drupal\Tests\Component\Plugin\Factory\StubReflectionFactory extends \Drupal\Component\Plugin\Factory\ReflectionFactory

Expanded class hierarchy of StubReflectionFactory

File

core/tests/Drupal/Tests/Component/Plugin/Factory/ReflectionFactoryTest.php, line 143
Contains \Drupal\Tests\Component\Plugin\Factory\ReflectionFactoryTest.

Namespace

Drupal\Tests\Component\Plugin\Factory
View source
class StubReflectionFactory extends ReflectionFactory {

  /**
   * {@inheritdoc}
   */
  public static function getPluginClass($plugin_id, $plugin_definition = NULL, $required_interface = NULL) {

    // Return the class name from the plugin definition.
    return $plugin_definition[$plugin_id]['class'];
  }

}

Members