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?
Advertisement
Answer
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 PHPUnitFrameworkTestCase; use SymplifyEasyTestingPHPUnitBehaviorDirectoryAssertableTrait; final class SomeTest extends TestCase { use DirectoryAssertableTrait; public function testSuccess(): void { $this->assertDirectoryEquals(__DIR__ . '/first_directory', __DIR__ . '/second_directory'); } }