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

[TEST] tests code cleanup #618

Merged
merged 4 commits into from
Aug 21, 2017
Merged

Conversation

mhujer
Copy link
Contributor

@mhujer mhujer commented Aug 11, 2017

Depends on #612 (should be merged first)

  • merge 612

Reasoning for each change is included in the individual commit messages.

Reason - when the class is renamed or removed, it will be detected much faster.
It helps with the static analysis of the code (also used by IDEs)
assertEquals() means ==
assertSame() is ===

Can cause tests not detecting issues, because different instances of
same class with same data are equal, but not the same.
@mhujer
Copy link
Contributor Author

mhujer commented Aug 20, 2017

@polyfractal I've rebased this and it is ready for review.

@polyfractal
Copy link
Contributor

LGTM, thanks for these :)

Looking through the affected code, it reminds me that there are still a few unit tests that still rely on an externally running cluster (e.g. SniffingConnectionPoolIntegrationTest() does a ping, testCustomQueryParams() does an exists call) which is obviously not great for unit tests. Should be mocked out instead.

I'll open an issue so that these don't continue being forgotten about :)

@polyfractal polyfractal merged commit dc5d18c into elastic:master Aug 21, 2017
@mhujer mhujer deleted the mh-tests-improvements branch August 22, 2017 05:26
p365labs pushed a commit to p365labs/elasticsearch-php that referenced this pull request Sep 10, 2017
* [TEST] use ::class instead of classname string

Reason - when the class is renamed or removed, it will be detected much faster.
It helps with the static analysis of the code (also used by IDEs)

* [TEST] use assertSame() instead of assertEquals()

assertEquals() means ==
assertSame() is ===

Can cause tests not detecting issues, because different instances of
same class with same data are equal, but not the same.

* [TEST] convert array() to [] syntax

* [TEST] $this->assert* should be used

See
sebastianbergmann/phpunit#1914 (comment)
p365labs pushed a commit to p365labs/elasticsearch-php that referenced this pull request Sep 10, 2017
* [TEST] use ::class instead of classname string

Reason - when the class is renamed or removed, it will be detected much faster.
It helps with the static analysis of the code (also used by IDEs)

* [TEST] use assertSame() instead of assertEquals()

assertEquals() means ==
assertSame() is ===

Can cause tests not detecting issues, because different instances of
same class with same data are equal, but not the same.

* [TEST] convert array() to [] syntax

* [TEST] $this->assert* should be used

See
sebastianbergmann/phpunit#1914 (comment)
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