Skip to content

Commit 3c98e41

Browse files
author
Claude
committed
test: fix assertCanonical expected value to use path only
assertCanonical() compares against the path component of the redirect URL, not the full URL. Use parse_url() to extract the path from wp_get_attachment_url().
1 parent cafba11 commit 3c98e41

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

tests/phpunit/tests/canonical/attachmentRedirect.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,10 @@ public function test_pretty_permalink_attachment_redirects_when_pages_disabled()
4646
update_option( 'wp_attachment_pages_enabled', 0 );
4747
$this->set_permalink_structure( '/%postname%/' );
4848

49-
$expected_url = wp_get_attachment_url( self::$attachment->ID );
49+
// assertCanonical compares against the path component only.
50+
$expected_path = parse_url( wp_get_attachment_url( self::$attachment->ID ), PHP_URL_PATH );
5051

51-
$this->assertCanonical( '/test-image-jpg/', $expected_url );
52+
$this->assertCanonical( '/test-image-jpg/', $expected_path );
5253
}
5354

5455
/**
@@ -58,8 +59,9 @@ public function test_query_var_attachment_redirects_when_pages_disabled() {
5859
update_option( 'wp_attachment_pages_enabled', 0 );
5960
$this->set_permalink_structure( '/%postname%/' );
6061

61-
$expected_url = wp_get_attachment_url( self::$attachment->ID );
62+
// assertCanonical compares against the path component only.
63+
$expected_path = parse_url( wp_get_attachment_url( self::$attachment->ID ), PHP_URL_PATH );
6264

63-
$this->assertCanonical( '/?attachment_id=' . self::$attachment->ID, $expected_url );
65+
$this->assertCanonical( '/?attachment_id=' . self::$attachment->ID, $expected_path );
6466
}
6567
}

0 commit comments

Comments
 (0)