1

I have 2 directories, multiple files, basically text formats.

  • They should be equal.
  • I need to know what files are missing/extra (diff will).

What method should I use?

Tomas Votruba
  • 23,240
  • 9
  • 79
  • 115

1 Answers1

0

2020 Open-Source Package Answer

PHPUnit is still missing this feature, and we needed it to simplify generator tests. So we made a small package symplify/easy-testing that covers it.

The package:

  • compares files by their relivate name
  • compares their content

1. Install

composer require symplify/easy-testing --dev

2. Use

Add DirectoryAssertableTrait trait to your test case and use like this:

<?php

use PHPUnit\Framework\TestCase;
use Symplify\EasyTesting\PHPUnit\Behavior\DirectoryAssertableTrait;

final class SomeTest extends TestCase
{
    use DirectoryAssertableTrait;

    public function testSuccess(): void
    {
        $this->assertDirectoryEquals(__DIR__ . '/first_directory', __DIR__ . '/second_directory');
    }
}
Tomas Votruba
  • 23,240
  • 9
  • 79
  • 115