From b1fde1d81e21e21747eabccd44425fccaca90f17 Mon Sep 17 00:00:00 2001 From: Christian Kuhn <lolli@schwarzbu.ch> Date: Wed, 26 Oct 2022 15:30:50 +0200 Subject: [PATCH] [TASK] Avoid testing 'non-writable' directory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Testing 'non-writable' directories is flaky in real life since it depends on the user that executes these tests. On gitlab CI, it is useless a-priori, since gitlab runs as root in containers. Establishing a vfs for this does not help us much, especially when it just tests if some exception is thrown, which is done obviously when reading code. This vfsStream usage is simply not worth the dependency. Resolves: #98932 Related: #97762 Releases: main Change-Id: Ifd813d47607e3760e2e617b93a56a59773bc4e62 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/76296 Tested-by: Stefan Bürk <stefan@buerk.tech> Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de> Tested-by: core-ci <typo3@b13.com> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> Reviewed-by: Stefan Bürk <stefan@buerk.tech> Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> --- .../FolderStructure/DirectoryNodeTest.php | 21 ------------------- .../Unit/FolderStructure/FileNodeTest.php | 21 ------------------- 2 files changed, 42 deletions(-) diff --git a/typo3/sysext/install/Tests/Unit/FolderStructure/DirectoryNodeTest.php b/typo3/sysext/install/Tests/Unit/FolderStructure/DirectoryNodeTest.php index 4f943bb5c179..38188f9b78b4 100644 --- a/typo3/sysext/install/Tests/Unit/FolderStructure/DirectoryNodeTest.php +++ b/typo3/sysext/install/Tests/Unit/FolderStructure/DirectoryNodeTest.php @@ -17,7 +17,6 @@ declare(strict_types=1); namespace TYPO3\CMS\Install\Tests\Unit\FolderStructure; -use org\bovigo\vfs\vfsStream; use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Core\Messaging\FlashMessage; use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity; @@ -30,9 +29,6 @@ use TYPO3\CMS\Install\FolderStructure\NodeInterface; use TYPO3\CMS\Install\FolderStructure\RootNodeInterface; use TYPO3\CMS\Install\Tests\Unit\FolderStructureTestCase; -/** - * Test case - */ class DirectoryNodeTest extends FolderStructureTestCase { /** @@ -448,23 +444,6 @@ class DirectoryNodeTest extends FolderStructureTestCase self::assertSame(ContextualFeedbackSeverity::OK, $node->_call('createDirectory')->getSeverity()); } - /** - * @test - */ - public function createDirectoryReturnsErrorStatusIfDirectoryWasNotCreated(): void - { - $node = $this->getAccessibleMock(DirectoryNode::class, ['exists', 'getAbsolutePath', 'getRelativePathBelowSiteRoot'], [], '', false); - // using vfs here to avoid inconsistent behaviour of file systems concerning permissions - $root = vfsStream::setup(); - $path = $root->url() . '/typo3temp/var/tests/' . StringUtility::getUniqueId('root_'); - chmod($path, 00440); - $subPath = $path . '/' . StringUtility::getUniqueId('dir_'); - $node->expects(self::once())->method('exists')->willReturn(false); - $node->method('getAbsolutePath')->willReturn($subPath); - $node->method('getRelativePathBelowSiteRoot')->willReturn($subPath); - self::assertSame(ContextualFeedbackSeverity::ERROR, $node->_call('createDirectory')->getSeverity()); - } - /** * @test */ diff --git a/typo3/sysext/install/Tests/Unit/FolderStructure/FileNodeTest.php b/typo3/sysext/install/Tests/Unit/FolderStructure/FileNodeTest.php index b8648af53542..405045cdfc7d 100644 --- a/typo3/sysext/install/Tests/Unit/FolderStructure/FileNodeTest.php +++ b/typo3/sysext/install/Tests/Unit/FolderStructure/FileNodeTest.php @@ -17,7 +17,6 @@ declare(strict_types=1); namespace TYPO3\CMS\Install\Tests\Unit\FolderStructure; -use org\bovigo\vfs\vfsStream; use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Core\Messaging\FlashMessage; use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity; @@ -30,9 +29,6 @@ use TYPO3\CMS\Install\FolderStructure\NodeInterface; use TYPO3\CMS\Install\FolderStructure\RootNodeInterface; use TYPO3\CMS\Install\Tests\Unit\FolderStructureTestCase; -/** - * Test case - */ class FileNodeTest extends FolderStructureTestCase { /** @@ -564,23 +560,6 @@ class FileNodeTest extends FolderStructureTestCase self::assertTrue(is_file($path)); } - /** - * @test - */ - public function createFileReturnsErrorStatusIfFileWasNotCreated(): void - { - $node = $this->getAccessibleMock(FileNode::class, ['exists', 'getAbsolutePath', 'getRelativePathBelowSiteRoot'], [], '', false); - // using vfs here to avoid inconsistent behaviour of file systems concerning permissions - $root = vfsStream::setup(); - $path = $root->url() . '/typo3temp/var/tests/' . StringUtility::getUniqueId(); - chmod($path, 00440); - $subPath = $path . '/' . StringUtility::getUniqueId('file_'); - $node->expects(self::once())->method('exists')->willReturn(false); - $node->method('getAbsolutePath')->willReturn($subPath); - $node->method('getRelativePathBelowSiteRoot')->willReturn($subPath); - self::assertSame(ContextualFeedbackSeverity::ERROR, $node->_call('createFile')->getSeverity()); - } - /** * @test */ -- GitLab