You are here

public function SuperStaticCacheTest::testSuperCache in Tome 8

@covers \Drupal\tome_static_super_cache\SuperStaticCache::deleteAll

File

modules/tome_static/modules/tome_static_super_cache/tests/src/Kernel/SuperStaticCacheTest.php, line 31

Class

SuperStaticCacheTest
Tests that the super static cache works.

Namespace

Drupal\Tests\tome_static_super_cache\Kernel

Code

public function testSuperCache() {
  User::create([
    'uid' => 0,
    'status' => 0,
    'name' => '',
  ])
    ->save();

  /** @var \Drupal\tome_static\StaticGenerator $static */
  $static = \Drupal::service('tome_static.generator');
  DateFormat::create([
    'pattern' => 'D, m/d/Y - H:i',
    'id' => 'medium',
  ])
    ->save();

  /** @var \Drupal\node\Entity\Node $article */
  $article = Node::create([
    'type' => 'article',
    'title' => 'My article',
  ]);
  $article
    ->save();
  $path = '_entity:node:en:' . $article
    ->id();
  $this
    ->assertContains($path, $static
    ->getPaths());
  $static
    ->requestPath($path);
  $this
    ->assertNotContains($path, $static
    ->getPaths());
  drupal_flush_all_caches();
  $this
    ->assertNotContains($path, $static
    ->getPaths());
  $GLOBALS[SuperStaticCache::FULL_REBUILD_KEY] = TRUE;
  drupal_flush_all_caches();
  $this
    ->assertContains($path, $static
    ->getPaths());
}