/**
  * @covers ::useCaches
  */
 public function testUseCachesWithCachedDecoratedDiscovery()
 {
     $this->decoratedDiscovery = $this->getMockForAbstractClass(PluginDiscoveryDecoratorTestCachedDiscovery::class);
     $this->sut = new PluginDiscoveryDecorator($this->decoratedDiscovery);
     $this->decoratedDiscovery->expects($this->once())->method('clearCachedDefinitions');
     $this->decoratedDiscovery->expects($this->exactly(3))->method('getDefinitions')->willReturn([]);
     // There are no cached definitions yet, so this should call the decorated
     // discovery.
     $this->sut->getDefinitions();
     // This should return the cached definitions.
     $this->sut->getDefinitions();
     $this->sut->useCaches(FALSE);
     // This should return newly built definitions, so this should call the
     // decorated discovery.
     $this->sut->getDefinitions();
     // This should return newly built definitions again, because we disabled
     // caching.
     $this->sut->getDefinitions();
 }
 /**
  * Constructs a new instance.
  *
  * @param \Drupal\plugin\PluginType\PluginTypeInterface $plugin_type
  *   The plugin type of which to decorate definitions.
  * @param \Drupal\Component\Plugin\Discovery\DiscoveryInterface|NULL $decorated_discovery
  *   The decorated discovery, or NULL to use the plugin type's default
  *   discovery.
  */
 public function __construct(PluginTypeInterface $plugin_type, DiscoveryInterface $decorated_discovery = NULL)
 {
     parent::__construct($decorated_discovery ?: $plugin_type->getPluginManager());
     $this->pluginType = $plugin_type;
 }