‪TYPO3CMS  ‪main
CacheWarmupCommandTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
21 use TYPO3\CMS\Core\DependencyInjection\ContainerBuilder;
22 use TYPO3\CMS\Core\Package\PackageManager;
24 
26 {
30  public function ‪cachesCanBeWarmed(): void
31  {
32  $containerBuilder = $this->get(ContainerBuilder::class);
33  $packageManager = $this->get(PackageManager::class);
34  $diCacheIdentifier = $containerBuilder->getCacheIdentifier($packageManager);
35 
37  $result = $this->‪executeConsoleCommand('cache:warmup');
38 
39  self::assertEquals(0, $result['status']);
40  self::assertFileExists(‪Environment::getVarPath() . '/cache/code/di/' . $diCacheIdentifier . '.php');
41  self::assertFileExists(‪Environment::getVarPath() . '/cache/code/core/sites-configuration.php');
42  }
43 
47  public function ‪systemCachesCanBeWarmed(): void
48  {
49  $containerBuilder = $this->get(ContainerBuilder::class);
50  $packageManager = $this->get(PackageManager::class);
51  $diCacheIdentifier = $containerBuilder->getCacheIdentifier($packageManager);
52 
54  $result = $this->‪executeConsoleCommand('cache:warmup --group %s', 'system');
55 
56  self::assertEquals(0, $result['status']);
57  self::assertFileExists(‪Environment::getVarPath() . '/cache/code/di/' . $diCacheIdentifier . '.php');
58  self::assertFileExists(‪Environment::getVarPath() . '/cache/code/core/sites-configuration.php');
59  }
60 
64  public function ‪diCachesDoesNotWarmSystemCaches(): void
65  {
66  $containerBuilder = $this->get(ContainerBuilder::class);
67  $packageManager = $this->get(PackageManager::class);
68  $diCacheIdentifier = $containerBuilder->getCacheIdentifier($packageManager);
69 
71  $result = $this->‪executeConsoleCommand('cache:warmup -g %s', 'di');
72 
73  self::assertEquals(0, $result['status']);
74  self::assertFileExists(‪Environment::getVarPath() . '/cache/code/di/' . $diCacheIdentifier . '.php');
75  self::assertFileDoesNotExist(‪Environment::getVarPath() . '/cache/code/core/sites-configuration.php');
76  }
77 
82  {
83  $containerBuilder = $this->get(ContainerBuilder::class);
84  $packageManager = $this->get(PackageManager::class);
85  $diCacheIdentifier = $containerBuilder->getCacheIdentifier($packageManager);
86 
88  file_put_contents(
89  ‪Environment::getVarPath() . '/cache/code/di/' . $diCacheIdentifier . '.php',
90  'invalid php code'
91  );
92 
93  $result = $this->‪executeConsoleCommand('cache:warmup --group %s', 'system');
94 
95  self::assertEquals(0, $result['status']);
96  self::assertFileExists(‪Environment::getVarPath() . '/cache/code/di/' . $diCacheIdentifier . '.php');
97  }
98 }
‪TYPO3\CMS\Core\Tests\Functional\Command\CacheWarmupCommandTest\cachesCanBeWarmed
‪cachesCanBeWarmed()
Definition: CacheWarmupCommandTest.php:30
‪TYPO3\CMS\Core\Core\Environment\getVarPath
‪static getVarPath()
Definition: Environment.php:197
‪TYPO3\CMS\Core\Tests\Functional\Command\CacheWarmupCommandTest\diCachesDoesNotWarmSystemCaches
‪diCachesDoesNotWarmSystemCaches()
Definition: CacheWarmupCommandTest.php:64
‪TYPO3\CMS\Core\Utility\GeneralUtility\mkdir_deep
‪static mkdir_deep($directory)
Definition: GeneralUtility.php:1638
‪TYPO3\CMS\Core\Tests\Functional\Command\AbstractCommandTestCase\executeConsoleCommand
‪executeConsoleCommand(string $cmdline,... $args)
Definition: AbstractCommandTestCase.php:25
‪TYPO3\CMS\Core\Tests\Functional\Command\CacheWarmupCommandTest
Definition: CacheWarmupCommandTest.php:26
‪TYPO3\CMS\Core\Tests\Functional\Command\CacheWarmupCommandTest\systemCachesCanBeWarmed
‪systemCachesCanBeWarmed()
Definition: CacheWarmupCommandTest.php:47
‪TYPO3\CMS\Core\Tests\Functional\Command\CacheWarmupCommandTest\systemCachesCanBeWarmedIfCacheIsBroken
‪systemCachesCanBeWarmedIfCacheIsBroken()
Definition: CacheWarmupCommandTest.php:81
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:41
‪TYPO3\CMS\Core\Utility\GeneralUtility\rmdir
‪static bool rmdir($path, $removeNonEmpty=false)
Definition: GeneralUtility.php:1691
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:51
‪TYPO3\CMS\Core\Tests\Functional\Command
Definition: AbstractCommandTestCase.php:18
‪TYPO3\CMS\Core\Tests\Functional\Command\AbstractCommandTestCase
Definition: AbstractCommandTestCase.php:24