File tree 2 files changed +16
-2
lines changed
lib/internal/Magento/Framework
2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ public function getNewFileName(string $destinationFile)
28
28
if ($ this ->fileExist ($ destinationFile )) {
29
29
$ index = 1 ;
30
30
$ baseName = $ fileInfo ['filename ' ] . '. ' . $ fileInfo ['extension ' ];
31
- while (file_exists ($ fileInfo ['dirname ' ] . '/ ' . $ baseName )) {
31
+ while ($ this -> fileExist ($ fileInfo ['dirname ' ] . '/ ' . $ baseName )) {
32
32
$ baseName = $ fileInfo ['filename ' ] . '_ ' . $ index . '. ' . $ fileInfo ['extension ' ];
33
33
$ index ++;
34
34
}
Original file line number Diff line number Diff line change @@ -20,6 +20,11 @@ class NameTest extends \PHPUnit\Framework\TestCase
20
20
*/
21
21
private $ nonExistingFilePath ;
22
22
23
+ /**
24
+ * @var string
25
+ */
26
+ private $ multipleExistingFilePath ;
27
+
23
28
/**
24
29
* @var Name
25
30
*/
@@ -29,17 +34,26 @@ protected function setUp()
29
34
{
30
35
$ this ->name = new Name ();
31
36
$ this ->existingFilePath = __DIR__ . '/../_files/source.txt ' ;
37
+ $ this ->multipleExistingFilePath = __DIR__ . '/../_files/name.txt ' ;
32
38
$ this ->nonExistingFilePath = __DIR__ . '/../_files/file.txt ' ;
33
39
}
34
40
35
41
/**
36
42
* @test
37
43
*/
38
- public function testGetNewFileNameWhenFileExists ()
44
+ public function testGetNewFileNameWhenOneFileExists ()
39
45
{
40
46
$ this ->assertEquals ('source_1.txt ' , $ this ->name ->getNewFileName ($ this ->existingFilePath ));
41
47
}
42
48
49
+ /**
50
+ * @test
51
+ */
52
+ public function testGetNewFileNameWhenTwoFileExists ()
53
+ {
54
+ $ this ->assertEquals ('name_2.txt ' , $ this ->name ->getNewFileName ($ this ->multipleExistingFilePath ));
55
+ }
56
+
43
57
/**
44
58
* @test
45
59
*/
You can’t perform that action at this time.
0 commit comments