WordPress.org

Make WordPress Core

Opened 3 weeks ago

Closed 3 days ago

Last modified 2 days ago

#49365 closed enhancement (fixed)

Remove Tests_Post_Types::register_post_type()

Reported by: SergeyBiryukov Owned by: SergeyBiryukov
Milestone: 5.4 Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: good-first-bug has-patch
Focuses: Cc:

Description (last modified by SergeyBiryukov)

[36768] introduced Tests_Post_Types::register_post_type() as a helper for some tests in tests/phpunit/tests/post/types.php.

This method is only used in 6 tests (out of 36 in the file), is redundant, and causes a bit of confusion as to why some tests use that while others use register_post_type() directly.

Since register_post_type() returns the registered post type object on success,

$args = $this->register_post_type( array( ... ) )

can be replaced with:

$args = register_post_type( $this->post_type, array( ... ) );

Attachments (2)

49365.diff (2.7 KB) - added by varunshanbhag 2 weeks ago.
Updated 6 test to make them more uniform with other tests for register_post_type
49365.2.diff (3.4 KB) - added by gh640 3 days ago.

Download all attachments as: .zip

Change History (11)

#1 @SergeyBiryukov
3 weeks ago

  • Description modified (diff)

#2 @SergeyBiryukov
3 weeks ago

  • Description modified (diff)

@varunshanbhag
2 weeks ago

Updated 6 test to make them more uniform with other tests for register_post_type

#3 @varunshanbhag
2 weeks ago

  • Keywords has-patch added; needs-patch removed

#4 @SergeyBiryukov
2 weeks ago

  • Milestone changed from Awaiting Review to 5.5

@gh640
3 days ago

#5 follow-up: @gh640
3 days ago

I believe the method Tests_Post_Types::register_post_type() needs to be removed instead of changing only the arguments.

I run the test in my environment after applying the patch and it works well.

This is my first attempt to send a patch here and please let me know if there's anything wrong. Thank you in advance.

#6 in reply to: ↑ 5 ; follow-up: @SergeyBiryukov
3 days ago

Replying to gh640:

This is my first attempt to send a patch here and please let me know if there's anything wrong. Thank you in advance.

49365.2.diff looks perfect, thank you :)

#7 @SergeyBiryukov
3 days ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 47381:

Build/Test Tools: Remove redundant Tests_Post_Types::register_post_type() helper method, use register_post_type() directly.

Props gh640, varunshanbhag.
Fixes #49365.

#8 @SergeyBiryukov
3 days ago

  • Milestone changed from 5.5 to 5.4

#9 in reply to: ↑ 6 @gh640
2 days ago

Replying to SergeyBiryukov:

Great! Thank you very much :)

Note: See TracTickets for help on using tickets.