Revert "Add snapshot tests to PHPUnit"

This reverts commit fd9a18dd92.
This commit is contained in:
Oliver Davies 2023-12-16 00:43:57 +00:00
parent 892f602159
commit c7fddd8ca4

View file

@ -1,73 +0,0 @@
<?php
namespace App\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Finder\Finder;
/**
* @group snapshots
*/
class SnapshotTest extends TestCase
{
/**
* @var array<int, string>
*/
private static $configs = [
'drupal',
'drupal-commerce-kickstart',
'drupal-localgov',
'fractal',
];
public function testCompareFiles(): void
{
foreach (self::$configs as $config) {
$baseDir = getcwd() . "/tests/snapshots/output/{$config}";
$generatedDir = getcwd() . "/.ignored/snapshots/output/{$config}";
$this->runCliTool($config);
$baseFiles = $this->getFiles($baseDir);
foreach ($baseFiles as $file) {
$this->assertFileEquals(
expected: $baseDir . '/' . $file,
actual: $generatedDir . '/' . $file,
message: "Files do not match: {$file}",
);
}
}
}
private function runCliTool(string $config): void
{
$configFilePath = getcwd() . "/tests/snapshots/configs/{$config}.yaml";
$cliCommand = sprintf(
"%s app:generate --config-file %s --output-dir %s",
getcwd() . '/bin/build-configs',
$configFilePath,
getcwd() . "/.ignored/snapshots/output/{$config}",
);
exec($cliCommand);
}
/**
* @return array<int, string>
*/
private function getFiles(string $directory): array
{
$files = [];
$finder = new Finder();
$finder->in($directory)->files();
foreach ($finder as $file) {
$files[] = $file->getRelativePathname();
}
return $files;
}
}