function CacheFactoryTest::testCacheFactoryWithDefaultBinBackend
Same name and namespace in other branches
- 9 core/tests/Drupal/Tests/Core/Cache/CacheFactoryTest.php \Drupal\Tests\Core\Cache\CacheFactoryTest::testCacheFactoryWithDefaultBinBackend()
- 8.9.x core/tests/Drupal/Tests/Core/Cache/CacheFactoryTest.php \Drupal\Tests\Core\Cache\CacheFactoryTest::testCacheFactoryWithDefaultBinBackend()
- 10 core/tests/Drupal/Tests/Core/Cache/CacheFactoryTest.php \Drupal\Tests\Core\Cache\CacheFactoryTest::testCacheFactoryWithDefaultBinBackend()
Tests that the cache factory uses the correct default bin backend.
@covers ::__construct @covers ::get
File
-
core/
tests/ Drupal/ Tests/ Core/ Cache/ CacheFactoryTest.php, line 80
Class
- CacheFactoryTest
- @coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Cache%21CacheFactory.php/class/CacheFactory/11.x" title="CacheFactory" class="local">\Drupal\Core\Cache\CacheFactory</a> @group Cache
Namespace
Drupal\Tests\Core\CacheCode
public function testCacheFactoryWithDefaultBinBackend() : void {
// Ensure the default bin backends are used before the configured default.
$settings = new Settings([
'cache' => [
'default' => 'cache.backend.unused',
],
]);
$default_bin_backends = [
'render' => 'cache.backend.custom',
];
$cache_factory = new CacheFactory($settings, $default_bin_backends);
$container = new ContainerBuilder();
$cache_factory->setContainer($container);
$custom_default_backend_factory = $this->createMock('\\Drupal\\Core\\Cache\\CacheFactoryInterface');
$container->set('cache.backend.custom', $custom_default_backend_factory);
$render_bin = $this->createMock('\\Drupal\\Core\\Cache\\CacheBackendInterface');
$custom_default_backend_factory->expects($this->once())
->method('get')
->with('render')
->willReturn($render_bin);
$actual_bin = $cache_factory->get('render');
$this->assertSame($render_bin, $actual_bin);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.