| @@ -6,9 +6,8 @@ | ||
| 6 | 6 | |
| 7 | 7 | use DateTimeImmutable; |
| 8 | 8 | use Packetery\Module\Framework\WpAdapter; |
| 9 | 9 | use Packetery\Module\ModuleHelper; |
| 10 | -use Packetery\Nette\IOException; | |
| 11 | 10 | use PHPUnit\Framework\TestCase; |
| 12 | 11 | |
| 13 | 12 | class ModuleHelperTest extends TestCase { |
| 14 | 13 | public static function convertToCentimetersProvider(): array { |
| @@ -112,63 +111,6 @@ | ||
| 112 | 111 | $this->createMock( WpAdapter::class ) |
| 113 | 112 | ); |
| 114 | 113 | |
| 115 | 114 | $this->assertNull( $moduleHelper->getTranslatedStringFromDateTime( null ) ); |
| 116 | - } | |
| 117 | - | |
| 118 | - public function testInstantDeleteRemovesDirectorySafely(): void { | |
| 119 | - $tempDir = sys_get_temp_dir() . '/packeta-test-' . uniqid(); | |
| 120 | - $testFile = $tempDir . '/test-file.txt'; | |
| 121 | - | |
| 122 | - // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_mkdir | |
| 123 | - mkdir( $tempDir, 0755, true ); | |
| 124 | - // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_file_put_contents | |
| 125 | - file_put_contents( $testFile, 'test content' ); | |
| 126 | - | |
| 127 | - $this->assertDirectoryExists( $tempDir ); | |
| 128 | - $this->assertFileExists( $testFile ); | |
| 129 | - | |
| 130 | - ModuleHelper::instantDelete( $tempDir ); | |
| 131 | - | |
| 132 | - $this->assertDirectoryDoesNotExist( $tempDir ); | |
| 133 | - $this->assertDirectoryDoesNotExist( $tempDir . '-old' ); | |
| 134 | - } | |
| 135 | - | |
| 136 | - public function testInstantDeleteHandlesNonExistentDirectory(): void { | |
| 137 | - $nonExistentDir = sys_get_temp_dir() . '/packeta-test-nonexistent-' . uniqid(); | |
| 138 | - | |
| 139 | - $this->expectException( IOException::class ); | |
| 140 | - ModuleHelper::instantDelete( $nonExistentDir ); | |
| 141 | - } | |
| 142 | - | |
| 143 | - public function testInstantDeleteWithComplexDirectoryStructure(): void { | |
| 144 | - $tempDir = sys_get_temp_dir() . '/packeta-test-complex-' . uniqid(); | |
| 145 | - $subDir1 = $tempDir . '/subdir1'; | |
| 146 | - $subDir2 = $tempDir . '/subdir2'; | |
| 147 | - $file1 = $tempDir . '/file1.txt'; | |
| 148 | - $file2 = $subDir1 . '/file2.txt'; | |
| 149 | - $file3 = $subDir2 . '/file3.txt'; | |
| 150 | - | |
| 151 | - // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_mkdir | |
| 152 | - mkdir( $subDir1, 0755, true ); | |
| 153 | - // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_mkdir | |
| 154 | - mkdir( $subDir2, 0755, true ); | |
| 155 | - // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_file_put_contents | |
| 156 | - file_put_contents( $file1, 'content1' ); | |
| 157 | - // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_file_put_contents | |
| 158 | - file_put_contents( $file2, 'content2' ); | |
| 159 | - // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_file_put_contents | |
| 160 | - file_put_contents( $file3, 'content3' ); | |
| 161 | - | |
| 162 | - $this->assertDirectoryExists( $tempDir ); | |
| 163 | - $this->assertDirectoryExists( $subDir1 ); | |
| 164 | - $this->assertDirectoryExists( $subDir2 ); | |
| 165 | - $this->assertFileExists( $file1 ); | |
| 166 | - $this->assertFileExists( $file2 ); | |
| 167 | - $this->assertFileExists( $file3 ); | |
| 168 | - | |
| 169 | - ModuleHelper::instantDelete( $tempDir ); | |
| 170 | - | |
| 171 | - $this->assertDirectoryDoesNotExist( $tempDir ); | |
| 172 | - $this->assertDirectoryDoesNotExist( $tempDir . '-old' ); | |
| 173 | 115 | } |
| 174 | 116 | } |