Make WordPress Core

Opened 3 years ago

Closed 6 months ago

Last modified 6 months ago

#54245 closed defect (bug) (fixed)

Partially add unit tests for WP Upgrader

Reported by: jipmoors's profile jipmoors Owned by: hellofromtonya's profile hellofromTonya
Milestone: 6.4 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 (38)

#1 @SergeyBiryukov
3 years ago

  • Milestone changed from Awaiting Review to 5.9

#2 @jipmoors
3 years 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
3 years ago

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

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


3 years 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.


2 years ago

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


2 years ago

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


2 years ago

#8 @hellofromTonya
2 years 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.


2 years ago

#10 @costdev
2 years ago

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

#11 @hellofromTonya
2 years 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.


21 months ago

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


21 months ago

#14 @chaion07
21 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.


21 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
21 months ago

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

#17 @costdev
21 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.


20 months ago

#19 @costdev
20 months ago

#53997 was marked as a duplicate.

#20 @hellofromTonya
19 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.


17 months ago

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


17 months ago

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


16 months ago

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


14 months ago

#25 follow-up: @mukesh27
14 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
14 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.


14 months ago

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


14 months ago

#29 @mukesh27
14 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
14 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.

#31 @audrasjb
9 months ago

  • Milestone changed from 6.3 to 6.4

Moving to milestone 6.4 as WP 6.3 RC3 has been released.

This ticket was mentioned in PR #5556 on WordPress/wordpress-develop by @peterwilsoncc.


6 months ago
#32

Backport to 6.4 test for https://github.com/WordPress/wordpress-develop/pull/3044

Merges tests for https://core.trac.wordpress.org/ticket/54245 to the 6.4 branch.

The src changes and tests relating to the src changes have been excluded as 6.4 is currently in RC.

#33 @peterwilsoncc
6 months ago

There are src changes in @costdev's linked PR, #3044. Due to the late stage of the release cycle these will need to go in to 6.5.

I've linked PR #5556 targeting the 6.4 branch which removes the src changes and the tests relating to those changes.

I'd like to commit the original PR to trunk and backport the limited tests PR to 6.4 in order to get some tests in to the next release. Although the src changes in the original PR are minor, it's too late to get the bug fix in to 6.4.

#34 @peterwilsoncc
6 months ago

After discussing this with @costdev, we decided it best to commit the tests only to trunk and 6.4 and follow with the bug fixes for a ticket on 6.5.

#35 @peterwilsoncc
6 months ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 56992:

Build/Test tools: Introduce partial unit tests for WP_Upgrader.

Props jipmoors, karlijnbk, chaion07, cu121, martin.krcho, costdev, mukesh27, hellofromTonya, SergeyBiryukov, audrasjb, jrf.
Fixes #54245.

#36 @peterwilsoncc
6 months ago

In 56993:

Build/Test tools: Introduce partial unit tests for WP_Upgrader.

Props jipmoors, karlijnbk, chaion07, cu121, martin.krcho, costdev, mukesh27, hellofromTonya, SergeyBiryukov, audrasjb, jrf.
Merges [56992] to the 6.4 branch.
Fixes #54245.

@peterwilsoncc commented on PR #3044:


6 months ago
#38

Tests added in r56992 / https://github.com/WordPress/wordpress-develop/commit/b5392cc28c6f065227e9345cdb9ac266a0f9ee30 and subsequently backported to the 6.4 branch.

The src changes and the tests relating to those fixes were not included to allow for the backport, these will need to be done as a follow up during the 6.5 release cycle. As WordPress 6.4 is in the release candidate stage it's too late to include the bug fix.

Note: See TracTickets for help on using tickets.