function FileCacheFactoryTest::testGetDisabledFileCache

Same name and namespace in other branches
  1. 10 core/tests/Drupal/Tests/Component/FileCache/FileCacheFactoryTest.php \Drupal\Tests\Component\FileCache\FileCacheFactoryTest::testGetDisabledFileCache()
  2. 9 core/tests/Drupal/Tests/Component/FileCache/FileCacheFactoryTest.php \Drupal\Tests\Component\FileCache\FileCacheFactoryTest::testGetDisabledFileCache()
  3. 8.9.x core/tests/Drupal/Tests/Component/FileCache/FileCacheFactoryTest.php \Drupal\Tests\Component\FileCache\FileCacheFactoryTest::testGetDisabledFileCache()

@legacy-covers ::get

File

core/tests/Drupal/Tests/Component/FileCache/FileCacheFactoryTest.php, line 76

Class

FileCacheFactoryTest
Tests Drupal\Component\FileCache\FileCacheFactory.

Namespace

Drupal\Tests\Component\FileCache

Code

public function testGetDisabledFileCache() : void {
  // Ensure the returned FileCache is an instance of FileCache::class.
  $file_cache = FileCacheFactory::get('test_foo_settings', []);
  $this->assertInstanceOf(FileCache::class, $file_cache);
  $configuration = FileCacheFactory::getConfiguration();
  $configuration[FileCacheFactory::DISABLE_CACHE] = TRUE;
  FileCacheFactory::setConfiguration($configuration);
  // Ensure the returned FileCache is now an instance of NullFileCache::class.
  $file_cache = FileCacheFactory::get('test_foo_settings', []);
  $this->assertInstanceOf(NullFileCache::class, $file_cache);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.