Skip to content

Commit f8c08d0

Browse files
committed
Failing test for ignoreWhitespace
1 parent f0ed073 commit f8c08d0

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

tests/IgnoreWhitespaceTest.php

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
$this->assertSame(<<<'DIFF'
43+
@@ -2,9 +2,5 @@
44+
45+
function foo(\DateTimeImmutable $date)
46+
{
47+
- if ($date) {
48+
echo 'foo';
49+
- } else {
50+
- echo 'bar';
51+
- }
52+
}
53+
DIFF, $diff);
54+
}
55+
}

0 commit comments

Comments
 (0)