Repository navigation
Tests: Cover post_type_archive_title() - #15319
devmuhib009 wants to merge 1 commit into
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for this test-only addition covering post_type_archive_title() behavior.
No open issues 🎉
What changed in this PR
Adds unit tests for post_type_archive_title() to WordPress’s general template test suite, addressing Trac ticket #65819. No production code changes are included.
Changes:
- Verifies
nullis returned outside a post type archive. - Covers title display, returning the title with
$display = false, and custom prefixes. - Checks that the filter receives the title and post type and can modify the result.
| File | Description |
|---|---|
tests/phpunit/tests/general/postTypeArchiveTitle.php |
Adds a custom post type fixture and five tests for archive title behavior. |
Review effort: Balanced
huzaifaalmesbah
left a comment
There was a problem hiding this comment.
I left a few small notes inline.
AI Review: Opus 5.5
| public function test_post_type_archive_title_returns_when_display_is_false() { | ||
| $this->go_to( '/?post_type=' . self::POST_TYPE ); | ||
|
|
||
| $this->assertSame( 'Custom Books', post_type_archive_title( '', false ) ); |
There was a problem hiding this comment.
This one looks like a small coverage gap: the prefix is only tested when displaying, so a lost prefix in return $prefix . $title goes unnoticed. Could you add $this->assertSame( 'Archive: Custom Books', post_type_archive_title( 'Archive: ', false ) );?
| 2 | ||
| ); | ||
|
|
||
| $this->assertSame( 'Filtered: Custom Books (wptests_pt)', post_type_archive_title( '', false ) ); |
There was a problem hiding this comment.
Another small gap: the is_array( $post_type ) branch isn't reached yet. A query string won't get there, because is_post_type_archive() is false for an array, but set_query_var( 'post_type', array( self::POST_TYPE, 'post' ) ) after go_to() does. Could you add a test for it?
lancewillett
left a comment
There was a problem hiding this comment.
Reviewed the changed code against the implementation and existing coverage; no blocking issue found.
Validated with the related behavioral coverage patches on current trunk: 35 tests / 43 assertions in each of single-site and multisite, randomized seed 1101. No failures, errors, warnings, or skips.
Current-head CI and Copilot review checked.
AI review · gpt-6
Cover body-opening output, post type descriptions, archive descriptions and titles, and post type archive titles. Verify relevant display filters and return behavior. Developed in: #15240, #15241, #15242, #15315, #15319 Props devmuhib, huzaifaalmesbah. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@65171 602fd350-edb4-49c9-b593-d223f7449a82
Cover body-opening output, post type descriptions, archive descriptions and titles, and post type archive titles. Verify relevant display filters and return behavior. Developed in: WordPress/wordpress-develop#15240, WordPress/wordpress-develop#15241, WordPress/wordpress-develop#15242, WordPress/wordpress-develop#15315, WordPress/wordpress-develop#15319 Props devmuhib, huzaifaalmesbah. See #65819. Built from https://develop.svn.wordpress.org/trunk@65171 git-svn-id: http://core.svn.wordpress.org/trunk@64320 1a063a9b-81f0-0310-95a4-ce76da25c4cd
|
PR #15319 landed in https://core.trac.wordpress.org/changeset/65171 |
Trac ticket: https://core.trac.wordpress.org/ticket/65819
This PR adds unit tests for
post_type_archive_title()covering:nullwhen queried outside a post type archive$displayis false$prefixto the titlepost_type_archive_titlefilter hook