SmartTagTest.php in Tome 8
File
modules/tome_static/modules/tome_static_super_cache/tests/src/Kernel/SmartTagTest.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;
class SmartTagTest extends TestBase {
public static $modules = [
'tome_static',
'tome_static_super_cache',
'tome_static_super_cache_test',
'node',
'views',
];
public function testSmartTag() {
$this
->installConfig([
'tome_static_super_cache_test',
]);
$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',
]);
drupal_static_reset('tome_static_super_cache_entity_insert');
$article
->save();
$this
->assertContains('/test', $static
->getPaths());
$static
->requestPath('/test');
$this
->assertNotContains('/test', $static
->getPaths());
drupal_static_reset('tome_static_super_cache_entity_insert');
$article
->save();
$this
->assertContains('/test', $static
->getPaths());
$static
->requestPath('/test');
$this
->assertNotContains('/test', $static
->getPaths());
$article = Node::create([
'type' => 'article',
'title' => 'My other article',
]);
$article
->setUnpublished();
drupal_static_reset('tome_static_super_cache_entity_insert');
$article
->save();
$this
->assertNotContains('/test', $static
->getPaths());
$article
->setPublished();
drupal_static_reset('tome_static_super_cache_entity_insert');
$article
->save();
$this
->assertContains('/test', $static
->getPaths());
$static
->requestPath('/test');
$this
->assertNotContains('/test', $static
->getPaths());
}
}
Classes
Name |
Description |
SmartTagTest |
Tests that the smart tag views cache plugin works. |