123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <?php declare(strict_types=1);
- namespace SebastianBergmann\Diff\Output;
- use PHPUnit\Framework\TestCase;
- use SebastianBergmann\Diff\Differ;
- final class UnifiedDiffOutputBuilderTest extends TestCase
- {
-
- public function testCustomHeaderCanBeUsed(string $expected, string $from, string $to, string $header): void
- {
- $differ = new Differ(new UnifiedDiffOutputBuilder($header));
- $this->assertSame(
- $expected,
- $differ->diff($from, $to)
- );
- }
- public function headerProvider(): array
- {
- return [
- [
- "CUSTOM HEADER\n@@ @@\n-a\n+b\n",
- 'a',
- 'b',
- 'CUSTOM HEADER',
- ],
- [
- "CUSTOM HEADER\n@@ @@\n-a\n+b\n",
- 'a',
- 'b',
- "CUSTOM HEADER\n",
- ],
- [
- "CUSTOM HEADER\n\n@@ @@\n-a\n+b\n",
- 'a',
- 'b',
- "CUSTOM HEADER\n\n",
- ],
- [
- "@@ @@\n-a\n+b\n",
- 'a',
- 'b',
- '',
- ],
- ];
- }
-
- public function testDiffWithLineNumbers($expected, $from, $to): void
- {
- $differ = new Differ(new UnifiedDiffOutputBuilder("--- Original\n+++ New\n", true));
- $this->assertSame($expected, $differ->diff($from, $to));
- }
- public function provideDiffWithLineNumbers(): array
- {
- return UnifiedDiffOutputBuilderDataProvider::provideDiffWithLineNumbers();
- }
- }
|