Make WordPress Core

Opened 20 months ago

Last modified 3 months ago

#54245 reviewing defect (bug)

Partially add unit tests for WP Upgrader

Reported by: jipmoors's profile jipmoors Owned by: hellofromtonya's profile hellofromTonya
Milestone: 6.3 Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: has-unit-tests has-patch
Focuses: Cc:

Description

During the Yoast contributor day, me and Karlijn Bok (will add user profile later) have been working on adding unit tests to the WP Upgrader class.

This does not add full coverage so it should not close #53997

PR: https://github.com/WordPress/wordpress-develop/pull/1751
Related ticket: #53997

Change History (30)

#1 @SergeyBiryukov
20 months ago

  • Milestone changed from Awaiting Review to 5.9

#2 @jipmoors
20 months ago

Additionally good to note; the total file has around 52% line-coverage due to accidental coverage from other classes.

I have not determined which tests these were - if somebody does; these could be improved by specifying better @covers tags on the methods or classes.

#3 @hellofromTonya
20 months ago

  • Owner set to hellofromTonya
  • Status changed from new to assigned

This ticket was mentioned in PR #1751 on WordPress/wordpress-develop by moorscode.


20 months ago
#4

  • Keywords has-patch added

This PR was created during the contributor day at Yoast on october 8th.
The focus of me and https://github.com/karlijnbok was to create test coverage for the WP Upgrader classes.

We've chosen the WP_Upgrader class to start off with, as this is a base class for different more specific upgrader classes.

As we both did not have a lot of recent experience in these classes, we decided to start with the simplest methods and work our way up.

We've added some small code adjustments to have better type safety.

The overal line-coverage of the class has increased to 24%.
We did not run branch or path coverage yet.

The restore_temp_backup has not fully been covered yet, running a coverage report will show this.

Trac ticket: https://core.trac.wordpress.org/ticket/54245

This ticket was mentioned in Slack in #core by audrasjb. View the logs.


19 months ago

This ticket was mentioned in Slack in #core-auto-updates by afragen. View the logs.


19 months ago

This ticket was mentioned in Slack in #core by audrasjb. View the logs.


19 months ago

#8 @hellofromTonya
18 months ago

  • Milestone changed from 5.9 to 6.0

5.9 Beta 1 is starting in the next 20ish minutes. Didn't get time in the cycle to review the PR properly. Moving to 6.0.

This ticket was mentioned in Slack in #core by audrasjb. View the logs.


18 months ago

#10 @costdev
14 months ago

  • Type changed from defect (bug) to task (blessed)

#11 @hellofromTonya
13 months ago

  • Milestone changed from 6.0 to 6.1

With 6.0 RC1 tomorrow, moving this ticket to 6.1.

This ticket was mentioned in Slack in #core by afragen. View the logs.


11 months ago

This ticket was mentioned in Slack in #core by martin.krcho. View the logs.


11 months ago

#14 @chaion07
11 months ago

Thanks, @jipmoors for reporting this. We reviewed this ticket during a recent bug-scrub session. Feedback received from the team:

  1. WP_Upgrader Class has additional lines of code which is new. Having the class reviewed would be a good idea.
  2. We feel that this ticket needs some attention. So requesting contributors to have a look before the next release if possible.

Cheers!

Props: @cu121 for the comment & @martin.krcho for pointing direction to the right ticket

This ticket was mentioned in PR #3044 on WordPress/wordpress-develop by costdev.


10 months ago
#15

This PR expands on PR 1754 to:

  • [x] bring PR 1754 in line with modern Core/Test standards including:
    • [x] improved test method descriptions.
    • [x] clearer test method names.
    • [x] data_ prefixes for data providers per Trac 53119.
    • x $message parameters per [Core Handbook: Writing PHPUnit Tests - Using Assertions].
    • [x] line length limits for contributor a11y consideration.
    • x filter callbacks changed to closures + static where appropriate per [Core Handbook: Writing PHPUnit Tests - One-off Functions for Hooks].
  • x adjust a refactor in [PR 1754] to remove a now unnecessary condition and restore a separated if to elseif.
  • x remove an unnecessary constant added to tests/phpunit/includes/bootstrap.php in [PR 1754].
  • [x] remove tests related to the Rollback feature, which is not yet committed.
    • These have also been updated with the above and retained in a separate branch for a later time.
  • [x] add missing generic strings to WP_Upgrader::generic_strings() that caused test failures.
  • [x] add more tests/datasets.

Line coverage is now 58.04% with trunk.

I believe this is as far as I can go for now with unit tests due to the use of general functions and the need to mock WPDB to ensure the tests are pure unit tests. Otherwise, integration tests can be added to cover the areas not covered by this PR.

Trac ticket: https://core.trac.wordpress.org/ticket/54245

#16 @costdev
10 months ago

@hellofromTonya @SergeyBiryukov @audrasjb @ironprogrammer PR 3044 is ready for review. If you have time to review, that would be great!

#17 @costdev
10 months ago

I've updated PR3044 to remove some source changes in WP_Upgrader and the related tests.

I'll open a separate ticket and submit a PR if/when PR3044 has been committed so that these source changes can be considered in their own context.

This ticket was mentioned in Slack in #core-auto-updates by costdev. View the logs.


9 months ago

#19 @costdev
9 months ago

#53997 was marked as a duplicate.

#20 @hellofromTonya
8 months ago

  • Milestone changed from 6.1 to 6.2
  • Type changed from task (blessed) to defect (bug)

Thank you @costdev for updating the PR. I'm sorry I didn't dive into it for a review during the 6.1 cycle. With 6.1 RC1 is tomorrow, moving this ticket to 6.2. Let's get it reviewed and committed.

This ticket was mentioned in Slack in #core-upgrade-install by afragen. View the logs.


7 months ago

This ticket was mentioned in Slack in #core-upgrade-install by afragen. View the logs.


6 months ago

This ticket was mentioned in Slack in #core-upgrade-install by costdev. View the logs.


6 months ago

This ticket was mentioned in Slack in #core by mukeshpanchal27. View the logs.


4 months ago

#25 follow-up: @mukesh27
4 months ago

This ticket was discussed during the recent bug scrub. It looks like it's unlikely that work will be done on this during the 6.2 cycle.

@hellofromTonya Is this still possible to land in 6.2, or should it be moved to Future Release for now?

#26 in reply to: ↑ 25 @hellofromTonya
4 months ago

Replying to mukesh27:

This ticket was discussed during the recent bug scrub. It looks like it's unlikely that work will be done on this during the 6.2 cycle.

@hellofromTonya Is this still possible to land in 6.2, or should it be moved to Future Release for now?

This is tests only and can be committed at any time during the 6.2 cycle. Let's leave it in the milestone. It's on my TODO list.

This ticket was mentioned in Slack in #core by costdev. View the logs.


3 months ago

This ticket was mentioned in Slack in #core by mukeshpanchal27. View the logs.


3 months ago

#29 @mukesh27
3 months ago

This ticket was discussed in the bug scrub.

@hellofromTonya Should it be reviewed and ready for committed prior to 6.2 RC1?

Additional props: @costdev

#30 @hellofromTonya
3 months ago

  • Component changed from Upgrade/Install to Build/Test Tools
  • Milestone changed from 6.2 to 6.3
  • Status changed from assigned to reviewing

Thanks for ping @mukesh27. Likely won't have time to get this one in before RC1.

But 6.3 alpha opens next week. Will ensure it gets reviewed and done.

Note: See TracTickets for help on using tickets.