peridot-php / leo

Next level assertion and matcher library for PHP
http://peridot-php.github.io/leo/
MIT License
35 stars 7 forks source link

Prototype diff formatting for discussion #30

Open agrrr3 opened 6 years ago

agrrr3 commented 6 years ago

This pull request contains a unfinished prototype for discussing an implementation of a feature.

It would be good to be able to see not only that actual and expected results are different, but also one would like to see in which way they differ.

I couldnt find a way to extend leo for diffing in plugin-kind of way. So I started prototyping.

This commit prototypes a possible implementation with the following properties

This indicates

So this bears the questions:

ragboyjr commented 6 years ago

@agrrr3 this is an interesting feature, can you paste some example output in here?

agrrr3 commented 6 years ago

@ragboyjr this is the result of using cogpowered\FineDiff with word granularity, html-renderer and some black art:

1) string ::magicReplacer when called with escaped LIKE statements should remove escapes from backslashed percentage signs if nested:
     Expected "AND DATE_OFFLINE > 'checkdate')))  AND fulltext_search.keywords LIKE '%nothilfe%' AND fulltext_search.doc_type = 'content'" to be identical to "AND DATE_OFFLINE > 'checkdate')))  AND fulltext_search.keywords LIKE '\%nothilfe\%' AND fulltext_search.doc_type = 'content'". 
     Difference: ...LIKE <del>'%nothilfe%' </del><ins>'\%nothilfe\%' </ins>AND fulltext_search.doc_ty...
     at /home/agrrr3/tests/numble/functions/StringTest.spec.php:322

So if the html gets rendered somewhere: ...LIKE '%nothilfe%' '\%nothilfe\%' AND fulltext_search.doc_ty...

ragboyjr commented 6 years ago

Ah, gotcha. I'm not opposed to this idea, let's make a list of tools that implementing diffing with nice output. Can you compare to what other matchers or test runners like PHPUnit, Kahlan, etc... use?