Skip to content

Commit 36e8df5

Browse files
committed
Show diff when regression test fails
1 parent d68b0a7 commit 36e8df5

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

test/Unit/RegressionTest.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
use Genkgo\Camt\Config;
88
use Genkgo\Camt\Reader;
9-
use PHPUnit\Framework\Assert;
109
use PHPUnit\Framework\TestCase;
1110

1211
class RegressionTest extends TestCase
@@ -39,7 +38,7 @@ public function testRegression(string $file, string $expectedFile): void
3938
}
4039

4140
/**
42-
* Custom assert that will not produce gigantic diff.
41+
* Custom assert that will also log entire, actual, content to file.
4342
*/
4443
private function assertFile(string $file, string $actualContent): void
4544
{
@@ -49,10 +48,7 @@ private function assertFile(string $file, string $actualContent): void
4948
@mkdir($dir, 0777, true);
5049
file_put_contents($logFile, $actualContent);
5150

52-
Assert::assertFileExists($file, 'Expected file must exist on disk, fix it with: cp ' . $logFile . ' ' . $file);
53-
$expected = file_get_contents($file);
54-
55-
Assert::assertTrue($expected === $actualContent, 'File content does not match, compare with: meld ' . $file . ' ' . $logFile);
51+
self::assertStringEqualsFile($file, $actualContent, 'File content does not match, compare with: meld ' . $file . ' ' . $logFile);
5652
}
5753

5854
public static function providerRegression(): iterable

0 commit comments

Comments
 (0)