File tree Expand file tree Collapse file tree 2 files changed +30
-2
lines changed
src/Module/Common/FileSystem Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -102,11 +102,11 @@ public static function removeDir(Path $path, bool $recursive = true): bool
102102 *
103103 * @param Path $from Source file path
104104 * @param Path $to Destination file path
105- * @param bool $overwrite Whether to overwrite the destination file if it exists (default: false )
105+ * @param bool $overwrite Whether to overwrite the destination file if it exists (default: true )
106106 *
107107 * @throws \RuntimeException If the move operation fails
108108 */
109- public static function moveFile (Path $ from , Path $ to , bool $ overwrite = false ): bool
109+ public static function moveFile (Path $ from , Path $ to , bool $ overwrite = true ): bool
110110 {
111111 if ($ from ->absolute () === $ to ->absolute ()) {
112112 return true ; // No need to move if paths are the same
Original file line number Diff line number Diff line change @@ -60,6 +60,34 @@ public function testDownloadsTrapPharSuccessfully(): void
6060 }
6161 }
6262
63+ public function testDownloadsTrapPharSuccessfullyWithForceOption (): void
64+ {
65+ // Arrange
66+ $ downloadConfig = new DownloadConfig ();
67+ $ downloadConfig ->software = 'trap ' ;
68+ $ downloadConfig ->version = '1.13.16 ' ;
69+ $ downloadConfig ->type = Type::Phar;
70+ $ downloadConfig ->extractPath = (string ) $ this ->destinationDir ;
71+
72+ // Act
73+ $ this ->dload ->addTask ($ downloadConfig );
74+ $ this ->dload ->run ();
75+ $ this ->dload ->addTask ($ downloadConfig , true );
76+ $ this ->dload ->run ();
77+
78+ // Assert - Check that trap.phar was downloaded
79+ $ expectedPharPath = (string ) $ this ->destinationDir ->join ('trap.phar ' );
80+ self ::assertFileExists ($ expectedPharPath , 'Trap PHAR should be downloaded to destination directory ' );
81+
82+ // Verify the file is not empty
83+ self ::assertGreaterThan (1024 , \filesize ($ expectedPharPath ), 'Downloaded PHAR should have substantial size ' );
84+
85+ // Verify file permissions (should be executable)
86+ if (PHP_OS_FAMILY !== 'Windows ' ) {
87+ self ::assertTrue (\is_executable ($ expectedPharPath ), 'PHAR file should be executable ' );
88+ }
89+ }
90+
6391 public function testDownloadsTrapBinary (): void
6492 {
6593 // Arrange
You can’t perform that action at this time.
0 commit comments