Skip to content

Use stricter assertions #1

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 1 commit into from
Mar 5, 2021
Merged

Use stricter assertions #1

merged 1 commit into from
Mar 5, 2021

Conversation

carusogabriel
Copy link
Contributor

@carusogabriel carusogabriel commented Mar 4, 2021

Hey @sarven, amazing tips on how to write better Unit Tests, thanks for putting it together 👏🏻 Here's my contribution to write better unit tests:

PHPUnit's assertEquals (internally ==) has its flaws. Let's use stricter assertions
as a better practice:

assertSame with arrays has other benefits: it ensures the order
of the items within the array matches the expectation. In some APIs,
that's crucial.

`assertEquals` (internally `==`) has its flaws. Let's use stricter assertions
as a better practice:

- `assertTrue`: `$expected === true`
- `assertFalse`: `$expected === false`
- `assertSame`: `$expected === $actual`

`assertSame` with arrays has other benefit: it ensures the order
of the items within the array matches the expectation. In some APIs,
that's crucial.
@sarven
Copy link
Owner

sarven commented Mar 5, 2021

Hi, thanks for the pull request. I had written TODO with changing these assertions but already it's done.

@sarven sarven merged commit a8f422c into sarven:main Mar 5, 2021
@carusogabriel carusogabriel deleted the ref/better-assertions branch March 5, 2021 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants