function YamlCacheCollectorTest::testUpdateCache

Same name and namespace in other branches
  1. main core/tests/Drupal/Tests/Core/Utility/YamlCacheCollectorTest.php \Drupal\Tests\Core\Utility\YamlCacheCollectorTest::testUpdateCache()

Tests the ::updateCache() function.

File

core/tests/Drupal/Tests/Core/Utility/YamlCacheCollectorTest.php, line 71

Class

YamlCacheCollectorTest
Tests Drupal\Core\Cache\CacheCollector.

Namespace

Drupal\Tests\Core\Utility

Code

public function testUpdateCache() : void {
  $this->cacheBackend
    ->set('key', [
    '/foo/bar/foo_bar.txt' => [
      'data' => [
        TRUE,
      ],
      'mtime' => 12345,
    ],
  ]);
  $this->collector
    ->set('/foo/bar/foo_bar.txt', [
    'data' => [
      'hello',
    ],
    'mtime' => 12345,
  ]);
  $this->collector
    ->updateCache();
  $this->assertSame($this->collector
    ->get('/foo/bar/foo_bar.txt'), []);
  $cached = $this->cacheBackend
    ->get('key');
  $this->assertArrayNotHasKey('foo_bar.txt', $cached->data);
}

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