Skip to content

Commit 4f96a32

Browse files
committed
COmplete multidirectional file sync test
1 parent 3f7cbdd commit 4f96a32

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

src/FileListing/File.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class File
2020
public function __construct(string $path, string $timestamp)
2121
{
2222
$this->path = $path;
23-
$this->timestamp = new Carbon($timestamp);
23+
$this->timestamp = Carbon::createFromTimestamp($timestamp);
2424
}
2525

2626
public function isNewerThan(File $file)

tests/Integration/MultiDirectionalFileSyncTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,19 @@ public function setupDirectory($name)
2222
mkdir($path, 0777, true);
2323
}
2424

25+
$numFiles = rand(1, 100);
26+
27+
$faker = Faker\Factory::create();
28+
29+
$monthInSeconds = 2592000;
30+
31+
for ($i=0; $i < $numFiles; $i++) {
32+
$filename = $faker->word().'.txt';
33+
$content = $faker->text(rand(5, 1000));
34+
file_put_contents($path.$filename, $content);
35+
touch($path.$filename, time() - rand(0, $monthInSeconds));
36+
}
37+
2538
$adapter = new Local($path);
2639
return new Filesystem($adapter);
2740
}
@@ -39,5 +52,23 @@ public function testMultiDirectionalFileSync()
3952
->with($directoryC)
4053
->withProgressBar()
4154
->begin();
55+
56+
$filesA = glob(__DIR__.'/Data/a/*.txt');
57+
$filesB = glob(__DIR__.'/Data/b/*.txt');
58+
$filesC = glob(__DIR__.'/Data/c/*.txt');
59+
60+
$this->assertSameSize($filesA, $filesB);
61+
$this->assertSameSize($filesA, $filesC);
62+
63+
foreach($filesA as $fileA) {
64+
$fileB = __DIR__.'/Data/b/'.basename($fileA);
65+
$fileC = __DIR__.'/Data/c/'.basename($fileA);
66+
67+
$this->assertFileExists($fileB);
68+
$this->assertFileExists($fileC);
69+
70+
$this->assertFileEquals($fileA, $fileB);
71+
$this->assertFileEquals($fileA, $fileC);
72+
}
4273
}
4374
}

0 commit comments

Comments
 (0)