sebastianbergmann/diff

Support simple colored diffs

dkarlovi opened this issue · 2 comments

When doing this in PHPUnit

static::assertEquals(['aa', 'bb'], ['aa', 'cc']);

Output comes out as

Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
 Array (
     0 => 'aa'
-    1 => 'bb'
+    1 => 'cc'
 )

but, if PHPUnit is in color mode, it could come out as

Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
Array (
    0 => 'aa'
-    1 => 'bb'
+    1 => 'cc'
)

The way to go about it seems like:

  1. add color mode to output here
  2. make PHPUnit tell Comparator to be in color mode
  3. make Comparator pass the information along

Don't know if I'm missing something or if this is the correct repo to create this issue, seems like the correct way forward.

I wouldn't increase the scope of the library with output formatters.

The lib creates strings in the well known/documented diff format, this should allow any to process the output and apply what ever operation on it (like adding console coloring and sending it to the console).