‪TYPO3CMS  9.5
Typo3tempFileServiceTest.php
Go to the documentation of this file.
1 <?php
2 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 
20 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
21 
25 class ‪Typo3tempFileServiceTest extends FunctionalTestCase
26 {
30  private ‪$directoryName;
31 
36 
37  protected function ‪setUp(): void
38  {
39  parent::setUp();
40  $this->directoryName = uniqid('test');
41  $this->directoryPath = $this->instancePath . '/typo3temp/assets/' . ‪$this->directoryName;
42  }
43 
44  protected function ‪tearDown(): void
45  {
46  parent::tearDown();
47  GeneralUtility::rmdir($this->directoryPath, true);
48  unset($this->directoryName, $this->directoryPath);
49  }
50 
55  {
56  $this->expectException(\RuntimeException::class);
57  $this->expectExceptionCode(1501781454);
58  $subject = new Typo3tempFileService();
59  $subject->clearAssetsFolder('/typo3temp/assets/' . $this->directoryName);
60  }
61 
65  public function ‪clearAssetsFolderClearsFolder()
66  {
67  GeneralUtility::mkdir_deep($this->directoryPath . '/a/b');
68  file_put_contents($this->directoryPath . '/c.css', '/* test */');
69  file_put_contents($this->directoryPath . '/a/b/c.css', '/* test */');
70  file_put_contents($this->directoryPath . '/a/b/d.css', '/* test */');
71 
72  $subject = new Typo3tempFileService();
73  $subject->clearAssetsFolder('/typo3temp/assets/' . $this->directoryName);
74 
75  self::assertDirectoryNotExists($this->directoryPath . '/a');
76  self::assertDirectoryExists($this->directoryPath);
77  self::assertFileNotExists($this->directoryPath . '/c.css');
78  }
79 }
‪TYPO3\CMS\Install\Tests\Functional\Service\Typo3tempFileServiceTest\setUp
‪setUp()
Definition: Typo3tempFileServiceTest.php:35
‪TYPO3\CMS\Install\Tests\Functional\Service\Typo3tempFileServiceTest
Definition: Typo3tempFileServiceTest.php:26
‪TYPO3\CMS\Install\Service\Typo3tempFileService
Definition: Typo3tempFileService.php:30
‪TYPO3\CMS\Install\Tests\Functional\Service\Typo3tempFileServiceTest\$directoryPath
‪string $directoryPath
Definition: Typo3tempFileServiceTest.php:33
‪TYPO3\CMS\Install\Tests\Functional\Service\Typo3tempFileServiceTest\clearAssetsFolderDetectsNonExistingFolder
‪clearAssetsFolderDetectsNonExistingFolder()
Definition: Typo3tempFileServiceTest.php:52
‪TYPO3\CMS\Install\Tests\Functional\Service\Typo3tempFileServiceTest\$directoryName
‪string $directoryName
Definition: Typo3tempFileServiceTest.php:29
‪TYPO3\CMS\Install\Tests\Functional\Service\Typo3tempFileServiceTest\tearDown
‪tearDown()
Definition: Typo3tempFileServiceTest.php:42
‪TYPO3\CMS\Install\Tests\Functional\Service\Typo3tempFileServiceTest\clearAssetsFolderClearsFolder
‪clearAssetsFolderClearsFolder()
Definition: Typo3tempFileServiceTest.php:63
‪TYPO3\CMS\Install\Tests\Functional\Service
Definition: Typo3tempFileServiceTest.php:3
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45