Skip to content

Commit

Permalink
fix directory compare returning no differences
Browse files Browse the repository at this point in the history
  • Loading branch information
bytestream committed Jun 15, 2021
1 parent 40fa5b9 commit 1df14ec
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/IO/Compare/CompareDirectory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class CompareDirectory extends Directory
public function diff(): array
{
$differences = [];
$this->each(function (SplFileInfo $file, SplFileInfo $otherPath) use ($differences) {
$this->each(function (SplFileInfo $file, SplFileInfo $otherPath) use (&$differences) {
$comparison = new CompareFile($file->getPathname(), $otherPath->getPathname());
if (! $comparison->hasDifferences()) {
return null;
Expand Down
4 changes: 3 additions & 1 deletion tests/CompareDirectoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
use PHPUnit\Framework\TestCase;
use SupportPal\LanguageTools\IO\Compare\CompareDirectory;

use function count;

class CompareDirectoryTest extends TestCase
{
public function testSuccess(): void
Expand All @@ -20,6 +22,6 @@ public function testFail(): void
$base = __DIR__.'/__fixtures__/fail';
$comparison = new CompareDirectory($base.'/en', $base.'/es');

$this->assertGreaterThan(0, $comparison->diff());
$this->assertGreaterThan(0, count($comparison->diff()));
}
}

0 comments on commit 1df14ec

Please sign in to comment.