sirbrillig / phpcs-changed

🐘 Run phpcs on files and only report new warnings/errors compared to the previous version.
MIT License
31 stars 11 forks source link

Introduce TestShell for making it easier to introduce new tests #30

Closed david-binda closed 4 years ago

david-binda commented 4 years ago

While working on the other PRs, I found it unnecessarily verbose to write an integration test.

Feels like it could be made easier and less error-prone (eg: having the class to throw an exception by default in case unknown command is run) in case the project would provide some helpers. Eg.: a TestShell class, which would do the heavy lifting, while letting the developer to only focus on registering the commands.

In the PR I'm also adding a test debug function implementation, which can be shared across the tests, again minimising the amount of code developer has to write (including the PHPCS exclusion comment).

Please, take this only as a proposal, and feel free to say "No" if you don't see the fit here :)

sirbrillig commented 4 years ago

This looks great! Yeah, having to mock everything for every integration test was getting pretty verbose. It was fine when there were just a couple of them but now we have a lot more things going on. This is a big improvement.

I merged your other PRs, causing conflicts here, but after a rebase I think this will be a great addition. Thank you.