Make WordPress Core

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#49365 closed enhancement (fixed)

Remove Tests_Post_Types::register_post_type()

Reported by: sergeybiryukov's profile SergeyBiryukov Owned by: sergeybiryukov's profile 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 5 years 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 5 years ago.

Download all attachments as: .zip

Change History (11)

#1 @SergeyBiryukov
5 years ago

  • Description modified (diff)

#2 @SergeyBiryukov
5 years ago

  • Description modified (diff)

@varunshanbhag
5 years ago

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

#3 @varunshanbhag
5 years ago

  • Keywords has-patch added; needs-patch removed

#4 @SergeyBiryukov
5 years ago

  • Milestone changed from Awaiting Review to 5.5

@gh640
5 years ago

#5 follow-up: @gh640
5 years 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
5 years 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
5 years 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
5 years ago

  • Milestone changed from 5.5 to 5.4

#9 in reply to: ↑ 6 @gh640
5 years ago

Replying to SergeyBiryukov:

Great! Thank you very much :)

Note: See TracTickets for help on using tickets.