WordPress.org

Make WordPress Core

Opened 9 months ago

Closed 8 months ago

Last modified 8 months ago

#46439 closed task (blessed) (duplicate)

Add missing unit tests for `get_page_by_title()`

Reported by: desrosj Owned by:
Milestone: Priority: normal
Severity: minor Version:
Component: Posts, Post Types Keywords: has-patch has-unit-tests
Focuses: Cc:
PR Number:

Description

While looking into the report in #46355, I noticed that there are no unit tests for get_page_by_title().

Attachments (1)

46439.diff (3.6 KB) - added by desrosj 9 months ago.

Download all attachments as: .zip

Change History (4)

@desrosj
9 months ago

#1 @birgire
8 months ago

Looks good @desrosj and runs successfully on my install.

Just minor things I noticed in 46439.diff:

  • I think we could delete this comment in test_get_page_by_title():
    // get_page_by_path() should return a post of the requested type before returning an attachment.
    
  • There's a global $wpdb; in test_get_page_by_title_with_special_characters() that's not needed.
  • Would be nice to have the file header with title, @since 5.2.0, etc.

#2 @desrosj
8 months ago

  • Milestone 5.2 deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Thanks for the review, @birgire! I dug a little deeper into Trac today and discovered #36905. That ticket has a unit test patch already and discusses whether to add caching. I am going to close this as a duplicate.

#3 @birgire
8 months ago

yeah good finding @desrosj, hopefully these can be merged later on, e.g. the tests related to ticket #46355 on special chars.

Note: See TracTickets for help on using tickets.