‪TYPO3CMS  11.5
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 
29 {
33  public function ‪cachesCanBeWarmed(): void
34  {
35  $containerBuilder = $this->get(ContainerBuilder::class);
36  $packageManager = $this->get(PackageManager::class);
37  $diCacheIdentifier = $containerBuilder->getCacheIdentifier($packageManager);
38 
40  $result = $this->‪executeConsoleCommand('cache:warmup');
41 
42  self::assertEquals(0, $result['status']);
43  self::assertFileExists(‪Environment::getVarPath() . '/cache/code/di/' . $diCacheIdentifier . '.php');
44  self::assertFileExists(‪Environment::getVarPath() . '/cache/code/core/sites-configuration.php');
45  }
46 
50  public function ‪systemCachesCanBeWarmed(): void
51  {
52  $containerBuilder = $this->get(ContainerBuilder::class);
53  $packageManager = $this->get(PackageManager::class);
54  $diCacheIdentifier = $containerBuilder->getCacheIdentifier($packageManager);
55 
57  $result = $this->‪executeConsoleCommand('cache:warmup --group %s', 'system');
58 
59  self::assertEquals(0, $result['status']);
60  self::assertFileExists(‪Environment::getVarPath() . '/cache/code/di/' . $diCacheIdentifier . '.php');
61  self::assertFileExists(‪Environment::getVarPath() . '/cache/code/core/sites-configuration.php');
62  }
63 
67  public function ‪diCachesDoesNotWarmSystemCaches(): void
68  {
69  $containerBuilder = $this->get(ContainerBuilder::class);
70  $packageManager = $this->get(PackageManager::class);
71  $diCacheIdentifier = $containerBuilder->getCacheIdentifier($packageManager);
72 
74  $result = $this->‪executeConsoleCommand('cache:warmup -g %s', 'di');
75 
76  self::assertEquals(0, $result['status']);
77  self::assertFileExists(‪Environment::getVarPath() . '/cache/code/di/' . $diCacheIdentifier . '.php');
78  self::assertFileDoesNotExist(‪Environment::getVarPath() . '/cache/code/core/sites-configuration.php');
79  }
80 
85  {
86  $containerBuilder = $this->get(ContainerBuilder::class);
87  $packageManager = $this->get(PackageManager::class);
88  $diCacheIdentifier = $containerBuilder->getCacheIdentifier($packageManager);
89 
91  file_put_contents(
92  ‪Environment::getVarPath() . '/cache/code/di/' . $diCacheIdentifier . '.php',
93  'invalid php code'
94  );
95 
96  $result = $this->‪executeConsoleCommand('cache:warmup --group %s', 'system');
97 
98  self::assertEquals(0, $result['status']);
99  self::assertFileExists(‪Environment::getVarPath() . '/cache/code/di/' . $diCacheIdentifier . '.php');
100  }
101 }
‪TYPO3\CMS\Core\Tests\Functional\Command\AbstractCommandTest\executeConsoleCommand
‪executeConsoleCommand(string $cmdline,... $args)
Definition: AbstractCommandTest.php:25
‪TYPO3\CMS\Core\Tests\Functional\Command\CacheWarmupCommandTest\cachesCanBeWarmed
‪cachesCanBeWarmed()
Definition: CacheWarmupCommandTest.php:33
‪TYPO3\CMS\Core\Tests\Functional\Command\CacheWarmupCommandTest\diCachesDoesNotWarmSystemCaches
‪diCachesDoesNotWarmSystemCaches()
Definition: CacheWarmupCommandTest.php:67
‪TYPO3\CMS\Core\Utility\GeneralUtility\mkdir_deep
‪static mkdir_deep($directory)
Definition: GeneralUtility.php:1908
‪TYPO3\CMS\Core\Tests\Functional\Command\CacheWarmupCommandTest
Definition: CacheWarmupCommandTest.php:29
‪TYPO3\CMS\Core\Tests\Functional\Command\CacheWarmupCommandTest\systemCachesCanBeWarmed
‪systemCachesCanBeWarmed()
Definition: CacheWarmupCommandTest.php:50
‪TYPO3\CMS\Core\Tests\Functional\Command\AbstractCommandTest
Definition: AbstractCommandTest.php:24
‪TYPO3\CMS\Core\Tests\Functional\Command\CacheWarmupCommandTest\systemCachesCanBeWarmedIfCacheIsBroken
‪systemCachesCanBeWarmedIfCacheIsBroken()
Definition: CacheWarmupCommandTest.php:84
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:43
‪TYPO3\CMS\Core\Utility\GeneralUtility\rmdir
‪static bool rmdir($path, $removeNonEmpty=false)
Definition: GeneralUtility.php:1961
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50
‪TYPO3\CMS\Core\Tests\Functional\Command
Definition: AbstractCommandTest.php:18
‪TYPO3\CMS\Core\Core\Environment\getVarPath
‪static string getVarPath()
Definition: Environment.php:218