WordPress.org

Make WordPress Core

Opened 20 months ago

Closed 13 months ago

Last modified 4 months ago

#38157 closed enhancement (fixed)

Add tests for get_post_type_labels()

Reported by: swissspidy Owned by: swissspidy
Milestone: 4.8 Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

Working on #26511 and #29783, I'd thought it would be a good idea to have tests covering get_post_type_labels() in case we'd have to do some refactoring.

Attachments (1)

38157.diff (4.6 KB) - added by swissspidy 20 months ago.

Download all attachments as: .zip

Change History (9)

@swissspidy
20 months ago

#1 @swissspidy
15 months ago

  • Milestone changed from Awaiting Review to 4.8

IIRC from #38218, some assertions need to be tweaked, but otherwise nothing speaks against adding tests.

#2 @jbpaul17
13 months ago

  • Keywords has-unit-tests added

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


13 months ago

#4 @swissspidy
13 months ago

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

#5 @swissspidy
13 months ago

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

In 40635:

Posts, Post Types: Add initial tests for get_post_type_labels().

See #38218.
Fixes #38157.

#6 @swissspidy
4 months ago

In 42490:

Posts, Post Types: Add tests for get_post_type_labels().

These were accidentally omitted in [38157].

See #38157.

#7 @birgire
4 months ago

Hi @swissspidy

When I skimmed over these methods in [42490] :

test_labels_should_be_added_when_registering_a_post_type()
test_label_should_be_derived_from_labels_when_registering_a_post_type()
test_should_fall_back_on_defaults_when_filtered_labels_do_not_contain_the_keys

I just recalled you comment here on 42044#comment:1 regarding the cleanup.

The first one calls unregister_post_type( 'foo' ) before the assertions but the latter two do it afterwards.

Would the note be relevant in this case?

Last edited 4 months ago by birgire (previous) (diff)

#8 @swissspidy
4 months ago

@birgire Good call! I haven't closely looked at the tests, but yes, that should generally be avoided. I'll try to have a look at it soon. Perhaps even by going through _all_ tests to improve this.

Note: See TracTickets for help on using tickets.