You are here

public function PluginDiscoveryDecoratorTest::testClearCachedDefinitionsWithUncachedDecoratedDiscovery in Plugin 8.2

@covers ::clearCachedDefinitions

File

tests/src/Unit/PluginDiscovery/PluginDiscoveryDecoratorTest.php, line 79

Class

PluginDiscoveryDecoratorTest
@coversDefaultClass \Drupal\plugin\PluginDiscovery\PluginDiscoveryDecorator

Namespace

Drupal\Tests\plugin\Unit\PluginDiscovery

Code

public function testClearCachedDefinitionsWithUncachedDecoratedDiscovery() {
  $this->decoratedDiscovery
    ->expects($this
    ->exactly(2))
    ->method('getDefinitions')
    ->willReturn([]);

  // There are no cached definitions yet.
  $this->sut
    ->getDefinitions();

  // This should return the cached definitions.
  $this->sut
    ->getDefinitions();
  $this->sut
    ->clearCachedDefinitions();

  // This should return newly built definitions.
  $this->sut
    ->getDefinitions();
}