kontenta / kontour

Admin page manager for Laravel
2 stars 1 forks source link

Start replacing regex assertions in tests #192

Closed bjuppa closed 4 years ago

bjuppa commented 4 years ago

assertRegExp() and assertNotRegExp() are deprecated and will be removed in PHPUnit 10.

We're using them quite a lot in our tests (more than a 100 times) and although it can be refactored to assertMatchesRegularExpression() it's better to try not using them at all. The tests become very hard to read when all it does is matching a massive regex.

So I've created a method that splits a string between > and < so we get an array of tags. Then more precise assertions can be made on those tags, instead of having them all in one big regex.

This PR contains updates to three tests (that were especially brittle), now using the new split instead of regex.

So this is just a start of a much bigger refactor, with the end goal of replacing the other 129 occurrences of regexp assertions with clearer tests! 😬

Also, the xml format for phpunit config has changed, so this PR updates that as well.

bjuppa commented 4 years ago

@erik-epineer do you think we can get this merged today?

It'd be great to have before tackling the Laravel 8 release later today in #190!

bjuppa commented 4 years ago

@erik-epineer I'll merge this PR without review now, as I'm really eager to start working on #190 😄

The PR is only changes to tests, so nothing public facing!