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

Migrate PHPUnit Tests and Use WordPress test lib instead of WP Mocks #1073

Draft
wants to merge 18 commits into
base: develop
Choose a base branch
from

Conversation

ravinderk
Copy link
Contributor

@ravinderk ravinderk commented Jun 9, 2023

🔴 This pull request is not ready for review.

Description of the Change

In a few cases, We found that Mocking WordPress (10UP\WP_Mock) for tests does not help to produce a reliable build. We decided to implement PHPUnit tests with WordPress.

Closes #

How to test the Change

  • Open the terminal and switch to the plugin root directory
  • Run composer install
  • Install WordPress and create a database tests/bin/install-wp-tests.sh distributor_tests root root
  • Run PHPUnit test vendor/bin/phpunit

Changelog Entry

Added - Migrate PHPUnit tests to WordPress from10UP/WP_Mock

Credits

Props @ravinderk

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

@ravinderk ravinderk self-assigned this Jul 7, 2023
@jeffpaul jeffpaul added this to the 2.0.0 milestone Jul 10, 2023
@jeffpaul
Copy link
Member

@ravinderk any chance of getting this wrapped up in the next week or so to be ready for the v2 release?

@peterwilsoncc peterwilsoncc modified the milestones: 2.0.0, 2.0.1 Sep 6, 2023
@jeffpaul jeffpaul mentioned this pull request Sep 14, 2023
16 tasks
@peterwilsoncc peterwilsoncc modified the milestones: 2.0.1, 2.1.0 Sep 19, 2023
@github-actions github-actions bot added the needs:refresh This requires a refreshed PR to resolve. label Feb 9, 2024
# Conflicts:
#	tests/php/DistributorPostTest.php
#	tests/php/NetworkSiteConnectionsTest.php
#	tests/php/WordPressExternalConnectionTest.php
#	tests/php/bootstrap.php
@github-actions github-actions bot removed the needs:refresh This requires a refreshed PR to resolve. label Feb 11, 2024
@ravinderk ravinderk removed their assignment Feb 21, 2024
@github-actions github-actions bot added the needs:refresh This requires a refreshed PR to resolve. label Feb 29, 2024
@jeffpaul
Copy link
Member

jeffpaul commented Jul 8, 2024

@10up/open-source-practice this would be a good PR to help pick up and get finished off

@github-actions github-actions bot removed the needs:refresh This requires a refreshed PR to resolve. label Jul 25, 2024
@faisal-alvi
Copy link
Member

Update:

  • resolved conflicts
  • fixed PHPUnit test failure issues
  • fixed already defined constants issue
  • added tests for NetworkSiteConnection class
  • ignore E2E failures, they're being addressed in another PR

Note: I'm not assigning this to myself to allow others to pick it up and work on the remaining files

@github-actions github-actions bot added the needs:refresh This requires a refreshed PR to resolve. label Aug 15, 2024
Copy link

@ravinderk thanks for the PR! Could you please rebase your PR on top of the latest changes in the base branch?

Comment on lines -30 to -48
*
* @method bool has_blocks()
* @method bool has_block( string $block_name )
* @method int get_the_ID()
* @method string get_permalink()
* @method string get_post_type()
* @method int|false get_post_thumbnail_id()
* @method string|false get_post_thumbnail_url( string $size = 'post-thumbnail' )
* @method string|false get_the_post_thumbnail( string $size = 'post-thumbnail', array $attr = '' )
* @method string get_canonical_url( string $canonical_url = '' )
* @method string get_author_name( string $author_name = '' )
* @method string get_author_link( string $author_link = '' )
* @method array get_meta()
* @method array get_terms()
* @method array get_media()
* @method array post_data()
* @method array to_insert( array $args = [] )
* @method array to_pull_list( array $args = [] )
* @method array to_rest( array $args = [] )
Copy link
Collaborator

Choose a reason for hiding this comment

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

This block is required to allow IDEs and docblock parsers to pick up the methods. They are all marked private so we can use a magic method to call them after ensuring the correct site is current on multisite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs:refresh This requires a refreshed PR to resolve.
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

4 participants