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

Update docs to explain how WP_Mock TestCase is preferable to extend than PhpUnit's #239

Merged

Conversation

unfulvio-godaddy
Copy link
Member

@unfulvio-godaddy unfulvio-godaddy commented Jan 9, 2024

Summary

Updates docs to make it clear that implementations should use WP_Mock own TestCase, ideally, or at least provide teardown overrides.

Closes: #238

Contributor checklist

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly
  • I have added tests to cover changes introduced by this pull request
  • All new and existing tests pass

Reviewer checklist

  • Code changes review
  • Documentation changes review
  • Doc examples should always reference WP_Mock own TestCase
  • Unit tests pass
  • Static analysis passes

@unfulvio-godaddy unfulvio-godaddy self-assigned this Jan 9, 2024
@coveralls
Copy link

coveralls commented Jan 9, 2024

Coverage Status

coverage: 66.445% (+0.1%) from 66.312%
when pulling 1517e83 on issue/238-update-docs-when-test-case-not-extended
into 4249c87 on trunk.

@BrianHenryIE
Copy link
Contributor

FTR: I don't use it by extending TestCase, I just run the global WP_Mock::setUp(); and WP_Mock::tearDown(); and it works great for me!

https://github.com/BrianHenryIE/bh-wp-autologin-urls/blob/ace7784c2c8b1427f3a96db5a1e9daa29dbb852e/tests/unit/api/class-api-unit-Test.php#L24-L34

@unfulvio-godaddy
Copy link
Member Author

@BrianHenryIE that is correct - as mentioned in the docs we are updating in this PR, you can override precisely those two methods to achieve the same thing. However, it's simpler to tell people to extend WP_Mock own test case (which in turn extends PHPUnit's own test case anyway). We mention the alternative you are using in the docs as per this PR. Feel free to comment further if you think we should add anything else, thank you!

@unfulvio-godaddy unfulvio-godaddy added the Documentation Updates to documentation label Jan 11, 2024
Co-authored-by: Ryan Neudorf <109976277+rneudorf-godaddy@users.noreply.github.com>
Co-authored-by: Drew Jaynes <113622064+ajaynes-godaddy@users.noreply.github.com>
Copy link
Contributor

@ajaynes-godaddy ajaynes-godaddy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Big improvement.

@unfulvio-godaddy unfulvio-godaddy merged commit 1bcc9a4 into trunk Jan 12, 2024
10 checks passed
@unfulvio-godaddy unfulvio-godaddy deleted the issue/238-update-docs-when-test-case-not-extended branch January 12, 2024 06:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Updates to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mocked user function remains mocked in separate test.
6 participants