Skip to content

Add a comparator to help with writing tests #90

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 5, 2019

Conversation

willemstuursma
Copy link
Contributor

PHPUnit offers the ability to add custom comparators. In particular these offer the ability to add nice error messages:

Screen Shot 2019-05-02 at 13 29 35

This is a rough PR as a first draft, if you are interested in this feature please let me know and I'll polish it up.

@mnapoli
Copy link
Member

mnapoli commented May 2, 2019

That sounds interesting!

So to sum up to use it I would need to run this:

\SebastianBergmann\Comparator\Factory::getInstance()->register(new \MyCLabs\Enum\PHPUnit\Comparator);

I've heard of PHPUnit "extensions" that can be added to phpunit.xml, do you know if those can be used as well to register the comparator?

@peter279k
Copy link

It looks like the Pretty CI is failed due to failed PSR-2 coding style check.

The detailed log is available here.

I think the coding style should be fixed :).

@mnapoli
Copy link
Member

mnapoli commented May 2, 2019

This is weird because the failures on EnumTest.php do not show up on master… I even rebuilt master right now and it's still green.

Maybe your branch is old, try rebasing your branch on master to have all the latest changes.

And then there's still one fix to do in your new file indeed.

@willemstuursma
Copy link
Contributor Author

I've heard of PHPUnit "extensions" that can be added to phpunit.xml, do you know if those can be used as well to register the comparator?

That's only possible for test listeners, not for custom Comparators.

@mnapoli
Copy link
Member

mnapoli commented May 5, 2019

Roger that!

Thank you for the PR.

@mnapoli mnapoli merged commit ab5bb58 into myclabs:master May 5, 2019
@willemstuursma willemstuursma deleted the comparator branch May 5, 2019 10:28
@willemstuursma
Copy link
Contributor Author

I'll create a PR later to update the readme with the new functionality.

@mnapoli
Copy link
Member

mnapoli commented May 5, 2019

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants