tome-8.x-1.x-dev/modules/tome_static/modules/tome_static_super_cache/tests/src/Kernel/SuperStaticCacheTest.php

modules/tome_static/modules/tome_static_super_cache/tests/src/Kernel/SuperStaticCacheTest.php
<?php

namespace Drupal\Tests\tome_static_super_cache\Kernel;

use Drupal\node\Entity\Node;
use Drupal\Tests\tome_base\Kernel\TestBase;
use Drupal\tome_static_super_cache\SuperStaticCache;
use Drupal\user\Entity\User;

/**
 * Tests that the super static cache works.
 *
 * @coversDefaultClass \Drupal\tome_static_super_cache\SuperStaticCache
 * @group tome
 */
class SuperStaticCacheTest extends TestBase {

  /**
   * {@inheritdoc}
   */
  protected static $modules = [
    'tome_static',
    'tome_static_super_cache',
    'node',
  ];

  /**
   * @covers \Drupal\tome_static_super_cache\SuperStaticCache::deleteAll
   */
  public function testSuperCache() {
    User::create([
      'uid' => 0,
      'status' => 0,
      'name' => '',
    ])->save();

    /** @var \Drupal\tome_static\StaticGenerator $static */
    $static = \Drupal::service('tome_static.generator');

    /** @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());
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc