Tests that discovered definitions are properly cached.
This comes in addition to DiscoveryTestBase::testDiscoveryInterface(), that test the basic discovery behavior.
public function testCachedDefinitions() {
$cache = cache($this->cacheBin);
// Check that nothing is cached initially.
$cached = $cache
->get($this->cacheKey);
$this
->assertIdentical($cached, FALSE, 'Cache is empty.');
// Get the definitions once, and check that they are present in the cache.
$definitions = $this->discovery
->getDefinitions();
$this
->assertIdentical($definitions, $this->expectedDefinitions, 'Definitions are correctly retrieved.');
$cached = $cache
->get($this->cacheKey);
$this
->assertIdentical($cached->data, $this->expectedDefinitions, 'Definitions are cached.');
// Check that the definitions are also cached in memory. Since the
// CacheDecorator::definitions property is protected, this is tested "from
// the outside" by wiping the cache entry, getting the definitions, and
// checking that the cache entry was not regenerated (thus showing that
// defintions were not fetched from the decorated discovery).
$cache
->delete($this->cacheKey);
$definitions = $this->discovery
->getDefinitions();
$cached = $cache
->get($this->cacheKey);
$this
->assertIdentical($cached, FALSE, 'Cache is empty.');
$this
->assertIdentical($definitions, $this->expectedDefinitions, 'Definitions are cached in memory.');
}