Skip to content

Commit 6d839fb

Browse files
committed
Failing test for ignoreWhitespace
1 parent f0ed073 commit 6d839fb

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

tests/IgnoreWhitespaceTest.php

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Jfcherng\Diff\Test;
6+
7+
use Jfcherng\Diff\DiffHelper;
8+
use Jfcherng\Diff\Renderer\RendererConstant;
9+
use PHPUnit\Framework\TestCase;
10+
11+
class IgnoreWhitespaceTest extends TestCase
12+
{
13+
14+
public function testIgnoreWhitespaces(): void
15+
{
16+
$old = <<<'PHP'
17+
<?php
18+
19+
function foo(\DateTimeImmutable $date)
20+
{
21+
if ($date) {
22+
echo 'foo';
23+
} else {
24+
echo 'bar';
25+
}
26+
}
27+
PHP;
28+
$new = <<<'PHP'
29+
<?php
30+
31+
function foo(\DateTimeImmutable $date)
32+
{
33+
echo 'foo';
34+
}
35+
PHP;
36+
37+
$diff = DiffHelper::calculate($old, $new, 'Unified', [
38+
'ignoreWhitespace' => true,
39+
], [
40+
'cliColorization' => RendererConstant::CLI_COLOR_DISABLE,
41+
]);
42+
echo $diff . "\n";
43+
$this->assertSame(<<<'DIFF'
44+
@@ -2,9 +2,5 @@
45+
46+
function foo(\DateTimeImmutable $date)
47+
{
48+
- if ($date) {
49+
echo 'foo';
50+
- } else {
51+
- echo 'bar';
52+
- }
53+
}
54+
DIFF, $diff);
55+
}
56+
57+
}

0 commit comments

Comments
 (0)