Make WordPress Core

Opened 8 years ago

Closed 7 years ago

Last modified 7 years ago

#38157 closed enhancement (fixed)

Add tests for get_post_type_labels()

Reported by: swissspidy's profile swissspidy Owned by: swissspidy's profile 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 8 years ago.

Download all attachments as: .zip

Change History (9)

@swissspidy
8 years ago

#1 @swissspidy
8 years 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
8 years ago

  • Keywords has-unit-tests added

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


8 years ago

#4 @swissspidy
8 years ago

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

#5 @swissspidy
7 years 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
7 years ago

In 42490:

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

These were accidentally omitted in [38157].

See #38157.

#7 @birgire
7 years 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 7 years ago by birgire (previous) (diff)

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