Changeset 60108
- Timestamp:
- 03/30/2025 11:32:38 PM (7 weeks ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/link-template.php
r59865 r60108 4064 4064 } 4065 4065 4066 if ( 'publish' !== $post->post_status) {4066 if ( 'publish' !== get_post_status( $post ) ) { 4067 4067 return false; 4068 4068 } -
trunk/tests/phpunit/tests/link/wpGetCanonicalUrl.php
r51125 r60108 1 1 <?php 2 3 2 /** 3 * Tests for the wp_get_canonical_url() function. 4 * 5 * @package WordPress 6 * @subpackage Link 7 */ 8 9 /** 10 * Class for Testing the wp_get_canonical_url() function. 11 * 4 12 * @group link 5 13 * @group canonical 6 14 * @covers ::wp_get_canonical_url 7 15 */ 8 class Tests_Link_wpGetCanonicalUrl extends WP_UnitTestCase { 16 class Tests_Link_WpGetCanonicalUrl extends WP_UnitTestCase { 17 /** 18 * The ID of the post. 19 * 20 * @var int 21 */ 9 22 public static $post_id; 10 23 24 /** 25 * The ID of the attachment. 26 * 27 * @var int 28 */ 29 public static $attachment_id; 30 31 /** 32 * Sets up the test environment before any tests are run. 33 * 34 * @param WP_UnitTest_Factory $factory The factory object. 35 */ 11 36 public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) { 12 37 self::$post_id = $factory->post->create( … … 16 41 ) 17 42 ); 43 44 self::$attachment_id = $factory->attachment->create_object( 45 array( 46 'file' => DIR_TESTDATA . '/images/canola.jpg', 47 'post_parent' => self::$post_id, 48 'post_status' => 'inherit', 49 ) 50 ); 18 51 } 19 52 … … 139 172 140 173 $this->assertSame( $expected, wp_get_canonical_url( self::$post_id ) ); 174 } 175 176 /** 177 * This test ensures that attachments with 'inherit' status properly receive a canonical URL. 178 * 179 * @ticket 63041 180 */ 181 public function test_attachment_canonical_url() { 182 $this->go_to( get_attachment_link( self::$attachment_id ) ); 183 $canonical_url = wp_get_canonical_url( self::$attachment_id ); 184 185 $this->assertNotFalse( $canonical_url, 'Attachment should have a canonical URL' ); 186 $this->assertSame( get_attachment_link( self::$attachment_id ), $canonical_url, 'Canonical URL should match the attachment permalink' ); 141 187 } 142 188
Note: See TracChangeset
for help on using the changeset viewer.