SuperStaticCacheTest.php in Tome 8
File
modules/tome_static/modules/tome_static_super_cache/tests/src/Kernel/SuperStaticCacheTest.php
View source
<?php
namespace Drupal\Tests\tome_static_super_cache\Kernel;
use Drupal\Core\Datetime\Entity\DateFormat;
use Drupal\node\Entity\Node;
use Drupal\Tests\tome_base\Kernel\TestBase;
use Drupal\tome_static_super_cache\SuperStaticCache;
use Drupal\user\Entity\User;
class SuperStaticCacheTest extends TestBase {
public static $modules = [
'tome_static',
'tome_static_super_cache',
'node',
];
public function testSuperCache() {
User::create([
'uid' => 0,
'status' => 0,
'name' => '',
])
->save();
$static = \Drupal::service('tome_static.generator');
DateFormat::create([
'pattern' => 'D, m/d/Y - H:i',
'id' => 'medium',
])
->save();
$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());
}
}