-
Notifications
You must be signed in to change notification settings - Fork 653
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BUGFIX] Consider all elements in typo3temp/assets/ when clearing
Only first level elements were considered when clearing assets in typo3temp/assets/ using corresponding functionality in maintenance section of the TYPO3 install tool. Resolves: #89569 Releases: master, 9.5 Change-Id: I9237aa3c6200b57cf4da256531b25062f52708ee Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/62179 Tested-by: TYPO3com <noreply@typo3.com> Tested-by: Benni Mack <benni@typo3.org> Tested-by: Susanne Moog <look@susi.dev> Reviewed-by: Benni Mack <benni@typo3.org> Reviewed-by: Daniel Goerz <daniel.goerz@posteo.de> Reviewed-by: Susanne Moog <look@susi.dev>
- Loading branch information
1 parent
4e880df
commit fea0bdc
Showing
2 changed files
with
88 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
typo3/sysext/install/Tests/Functional/Service/Typo3tempFileServiceTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
namespace TYPO3\CMS\Install\Tests\Functional\Service; | ||
|
||
/* | ||
* This file is part of the TYPO3 CMS project. | ||
* | ||
* It is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License, either version 2 | ||
* of the License, or any later version. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE.txt file that was distributed with this source code. | ||
* | ||
* The TYPO3 project - inspiring people to share! | ||
*/ | ||
|
||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
use TYPO3\CMS\Install\Service\Typo3tempFileService; | ||
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; | ||
|
||
/** | ||
* Test case | ||
*/ | ||
class Typo3tempFileServiceTest extends FunctionalTestCase | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private $directoryName; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $directoryPath; | ||
|
||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
$this->directoryName = uniqid('test'); | ||
$this->directoryPath = $this->instancePath . '/typo3temp/assets/' . $this->directoryName; | ||
} | ||
|
||
protected function tearDown(): void | ||
{ | ||
parent::tearDown(); | ||
GeneralUtility::rmdir($this->directoryPath, true); | ||
unset($this->directoryName, $this->directoryPath); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function clearAssetsFolderDetectsNonExistingFolder() | ||
{ | ||
$this->expectException(\RuntimeException::class); | ||
$this->expectExceptionCode(1501781454); | ||
$subject = new Typo3tempFileService(); | ||
$subject->clearAssetsFolder('/typo3temp/assets/' . $this->directoryName); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function clearAssetsFolderClearsFolder() | ||
{ | ||
GeneralUtility::mkdir_deep($this->directoryPath . '/a/b'); | ||
file_put_contents($this->directoryPath . '/c.css', '/* test */'); | ||
file_put_contents($this->directoryPath . '/a/b/c.css', '/* test */'); | ||
file_put_contents($this->directoryPath . '/a/b/d.css', '/* test */'); | ||
|
||
$subject = new Typo3tempFileService(); | ||
$subject->clearAssetsFolder('/typo3temp/assets/' . $this->directoryName); | ||
|
||
self::assertDirectoryNotExists($this->directoryPath . '/a'); | ||
self::assertDirectoryExists($this->directoryPath); | ||
self::assertFileNotExists($this->directoryPath . '/c.css'); | ||
} | ||
} |