Skip to content

Commit a65ec6b

Browse files
committed
Add more tests
1 parent 5b91f82 commit a65ec6b

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

tests/Diff/DiffOptionsTest.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Tests\Diff;
6+
7+
use PHPUnit\Framework\TestCase;
8+
use jblond\Diff;
9+
10+
class DiffOptionsTest extends TestCase
11+
{
12+
public function testIgnoreWhitespace()
13+
{
14+
$diff = new Diff("Hello World", "Hello World", ['ignoreWhitespace' => true]);
15+
$this->assertTrue($diff->isIdentical());
16+
}
17+
18+
public function testIgnoreCase()
19+
{
20+
$diff = new Diff("Hello", "hello", ['ignoreCase' => true]);
21+
$this->assertTrue($diff->isIdentical());
22+
}
23+
24+
public function testIgnoreLines()
25+
{
26+
$a = "line1\n// comment\nline2";
27+
$b = "line1\n// comment\nline2";
28+
29+
$diff = new Diff($a, $b, ['ignoreLines' => ['// comment']]);
30+
31+
$this->assertTrue($diff->isIdentical());
32+
}
33+
34+
35+
public function testContextOption()
36+
{
37+
$a = "A\nB\nC\nD";
38+
$b = "A\nX\nC\nD";
39+
$diff = new Diff($a, $b, ['context' => 0]);
40+
$this->assertFalse($diff->isIdentical());
41+
}
42+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace Tests\Diff\Renderer\Cli;
4+
5+
use PHPUnit\Framework\TestCase;
6+
use jblond\Diff;
7+
8+
class CliTest extends TestCase
9+
{
10+
public function testCliRendererWithColors(): void
11+
{
12+
$diff = new Diff("foo", "bar");
13+
$renderer = new Diff\Renderer\Text\UnifiedCli(['cliColor' => true]);
14+
$output = $diff->render($renderer);
15+
$this->assertStringContainsString("\033[", $output); // ANSI escape
16+
}
17+
}

0 commit comments

Comments
 (0)