Skip to content
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

Specializations of assertEquals() and assertNotEquals() #3340

Closed
sebastianbergmann opened this issue Oct 11, 2018 · 4 comments
Closed

Specializations of assertEquals() and assertNotEquals() #3340

sebastianbergmann opened this issue Oct 11, 2018 · 4 comments
Assignees
Labels
type/enhancement A new idea that should be implemented
Milestone

Comments

@sebastianbergmann
Copy link
Owner

sebastianbergmann commented Oct 11, 2018

Implement the following methods

  • assertEqualsCanonicalizing()
  • assertEqualsIgnoringCase()
  • assertEqualsWithDelta()
  • assertNotEqualsCanonicalizing()
  • assertNotEqualsIgnoringCase()
  • assertNotEqualsWithDelta()

to replace the respective optional parameters for assertEquals() and assertNotEquals().

@stof
Copy link
Contributor

stof commented Oct 11, 2018

What about combinations of this flags:

  • asserting that 2 arrays contains the same case-insensitive values without a constraint on the order (canonicalize + ignore case)
  • asserting that 2 arrays contains the same floats (with delta) without a constraint on the order (canonicalize + delta)

The new methods don't account for all combinations of it (and the comparator library still has them as optional parameters AFAICT, so these combinations would still be supported by the lower-level code, unless the goal is to change these APIs too)

@sebastianbergmann
Copy link
Owner Author

I see your point, @stof. However, the combinatorial explosion made possible by mixing the various optional parameters of assertEquals() lead at least to confusion in the past. See #3317, for example. I would really like to reduce the complexity and confusion here. I am also not convinced that there are (enough) real use cases for the combinations to justify them.

I could see, however, keeping the $delta argument (somehow it feels "special") for assertEquals() and assertNotEquals() (removing the need for assertEqualsWithDelta() and assertNotEqualsWithDelta()) as well as adding $delta as an optional parameter to assertEqualsCanonicalizing() and assertNotEqualsCanonicalizing().

@stof
Copy link
Contributor

stof commented Oct 11, 2018

#3317 is not about assertEquals but about assertContains. AFAICT, ignoreCase should be working fine for arrays (in case they contain strings of course, otherwise there is no point for ignoring the case).

@stof
Copy link
Contributor

stof commented Oct 11, 2018

note however that I won't fight strongly for keeping the combination of canonicalize and ignoreCase, as I don't remember when I used ignoreCase in my own tests

jrfnl added a commit to jrfnl/wordpress-develop-official that referenced this issue Aug 16, 2020
…ta()`

The `$delta` parameter of the `assertEquals()` method was soft deprecated in PHPUnit 7.5, hard deprecated in PHPUnit 8.0 and the functionality was removed in PHPUnit 9.0.

The more specific `assertEqualsWithDelta()` (and `assertNotEqualsWithDelta()`) were introduced as replacements in PHPUnit 7.5.

Ref:
* https://github.com/sebastianbergmann/phpunit/blob/7.5.20/ChangeLog-7.5.md#750---2018-12-07
* sebastianbergmann/phpunit#3340
jrfnl added a commit to jrfnl/wordpress-develop-official that referenced this issue Aug 16, 2020
…ta()`

The `$delta` parameter of the `assertEquals()` method was soft deprecated in PHPUnit 7.5, hard deprecated in PHPUnit 8.0 and the functionality was removed in PHPUnit 9.0.

The more specific `assertEqualsWithDelta()` (and `assertNotEqualsWithDelta()`) were introduced as replacements in PHPUnit 7.5.

Ref:
* https://github.com/sebastianbergmann/phpunit/blob/7.5.20/ChangeLog-7.5.md#750---2018-12-07
* sebastianbergmann/phpunit#3340
jrfnl added a commit to jrfnl/wordpress-develop-official that referenced this issue Aug 16, 2020
…ta()`

The `$delta` parameter of the `assertEquals()` method was soft deprecated in PHPUnit 7.5, hard deprecated in PHPUnit 8.0 and the functionality was removed in PHPUnit 9.0.

The more specific `assertEqualsWithDelta()` (and `assertNotEqualsWithDelta()`) were introduced as replacements in PHPUnit 7.5.

Ref:
* https://github.com/sebastianbergmann/phpunit/blob/7.5.20/ChangeLog-7.5.md#750---2018-12-07
* sebastianbergmann/phpunit#3340
jrfnl added a commit to jrfnl/wordpress-develop-official that referenced this issue Aug 21, 2020
…ta()`

The `$delta` parameter of the `assertEquals()` method was soft deprecated in PHPUnit 7.5, hard deprecated in PHPUnit 8.0 and the functionality was removed in PHPUnit 9.0.

The more specific `assertEqualsWithDelta()` (and `assertNotEqualsWithDelta()`) were introduced as replacements in PHPUnit 7.5.

Ref:
* https://github.com/sebastianbergmann/phpunit/blob/7.5.20/ChangeLog-7.5.md#750---2018-12-07
* sebastianbergmann/phpunit#3340
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement A new idea that should be implemented
Projects
None yet
Development

No branches or pull requests

2 participants