zenstruck / browser

A fluent interface for your Symfony functional tests.
MIT License
185 stars 17 forks source link

fix: Complex test name normalization #139

Closed flohw closed 8 months ago

flohw commented 8 months ago

Hello!

As a Christmas gift I come here to preset the work to hopefully close #67 properly :santa: :partying_face:

I added the cases suggested by @0x346e3730 based on the existing test cases of @raneomik.

Let me know if the new algorithm is ok for you. The regexes are a bit stricter as there is with data set into, that's why I return early on line 117. It make the regexes a bit easier to read I think. That's not perfect to my eyes (depending on a static string is not algorithmically valid to me) but it may be enough. WDYT? I will also create named group to make the code clearer.

I didn't set cases stated by er1z in the issue as he didn't explain much about its problem.

If you look at it during this long weekend, please don't merge. I wanted to sign my commits but I have some issue with my passphrase memory :sweat_smile:

Thanks and have a nice week-end!

[EDIT]: Failing test seems unrelated.

kbond commented 8 months ago

Awesome, thanks for working on this @flohw! Let me know when it's ready and I'll merge!

flohw commented 8 months ago

Hi @kbond,

Chocolate activates some neurons! I added the regex group names to be more comprehensible. Also I updated the preg_replace to replace multiple non-word characters by a single hyphen to shorten the filename a bit.

For example for the dataset single quote for array index access with {{[\'id\']|filter(\'system\')}}st as a dataset name, the {{[ was transformed to --- in my previous version, it is a single - now.

Let me know if I need to make changes you have in mind.

Have a nice week-end!

kbond commented 8 months ago

Thanks @flohw!