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?
I have 2 directories, multiple files, basically text formats.
What method should I use?
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:
composer require symplify/easy-testing --dev
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');
}
}