public function PluginDiscoveryDecoratorTest::testClearCachedDefinitionsWithCachedDecoratedDiscovery in Plugin 8.2
@covers ::clearCachedDefinitions
File
- tests/
src/ Unit/ PluginDiscovery/ PluginDiscoveryDecoratorTest.php, line 97
Class
- PluginDiscoveryDecoratorTest
- @coversDefaultClass \Drupal\plugin\PluginDiscovery\PluginDiscoveryDecorator
Namespace
Drupal\Tests\plugin\Unit\PluginDiscoveryCode
public function testClearCachedDefinitionsWithCachedDecoratedDiscovery() {
$this->decoratedDiscovery = $this
->getMockForAbstractClass(PluginDiscoveryDecoratorTestCachedDiscovery::class);
$this->sut = new PluginDiscoveryDecorator($this->decoratedDiscovery);
$this->decoratedDiscovery
->expects($this
->once())
->method('clearCachedDefinitions');
$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();
}