Skip to content

Commit 4f67753

Browse files
author
Claude
committed
test: fix PHPCS equals sign alignment warnings
Use create_and_get() directly into self:: properties to avoid intermediate variables that trigger MultipleStatementAlignment warnings.
1 parent 37bdcdd commit 4f67753

1 file changed

Lines changed: 8 additions & 12 deletions

File tree

tests/phpunit/tests/canonical/attachmentRedirect.php

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
2525
self::$editor_user = $factory->user->create( array( 'role' => 'editor' ) );
2626

2727
// Unattached attachment.
28-
$unattached_id = $factory->post->create(
28+
self::$unattached = $factory->post->create_and_get(
2929
array(
3030
'post_type' => 'attachment',
3131
'post_title' => 'Unattached Image',
@@ -34,8 +34,7 @@ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
3434
'post_parent' => 0,
3535
)
3636
);
37-
update_post_meta( $unattached_id, '_wp_attached_file', '2025/01/unattached-image.jpg' );
38-
self::$unattached = get_post( $unattached_id );
37+
update_post_meta( self::$unattached->ID, '_wp_attached_file', '2025/01/unattached-image.jpg' );
3938

4039
// Attachment on a public post.
4140
self::$public_parent = $factory->post->create_and_get(
@@ -46,7 +45,7 @@ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
4645
'post_status' => 'publish',
4746
)
4847
);
49-
$attached_public_id = $factory->post->create(
48+
self::$attached_to_public = $factory->post->create_and_get(
5049
array(
5150
'post_type' => 'attachment',
5251
'post_title' => 'Public Attached Image',
@@ -55,8 +54,7 @@ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
5554
'post_parent' => self::$public_parent->ID,
5655
)
5756
);
58-
update_post_meta( $attached_public_id, '_wp_attached_file', '2025/01/public-attached-image.jpg' );
59-
self::$attached_to_public = get_post( $attached_public_id );
57+
update_post_meta( self::$attached_to_public->ID, '_wp_attached_file', '2025/01/public-attached-image.jpg' );
6058

6159
// Attachment on a private post.
6260
self::$private_parent = $factory->post->create_and_get(
@@ -68,7 +66,7 @@ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
6866
'post_author' => self::$editor_user,
6967
)
7068
);
71-
$attached_private_id = $factory->post->create(
69+
self::$attached_to_private = $factory->post->create_and_get(
7270
array(
7371
'post_type' => 'attachment',
7472
'post_title' => 'Private Attached Image',
@@ -77,8 +75,7 @@ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
7775
'post_parent' => self::$private_parent->ID,
7876
)
7977
);
80-
update_post_meta( $attached_private_id, '_wp_attached_file', '2025/01/private-attached-image.jpg' );
81-
self::$attached_to_private = get_post( $attached_private_id );
78+
update_post_meta( self::$attached_to_private->ID, '_wp_attached_file', '2025/01/private-attached-image.jpg' );
8279

8380
// Attachment on a draft post.
8481
self::$draft_parent = $factory->post->create_and_get(
@@ -90,7 +87,7 @@ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
9087
'post_author' => self::$editor_user,
9188
)
9289
);
93-
$attached_draft_id = $factory->post->create(
90+
self::$attached_to_draft = $factory->post->create_and_get(
9491
array(
9592
'post_type' => 'attachment',
9693
'post_title' => 'Draft Attached Image',
@@ -99,8 +96,7 @@ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
9996
'post_parent' => self::$draft_parent->ID,
10097
)
10198
);
102-
update_post_meta( $attached_draft_id, '_wp_attached_file', '2025/01/draft-attached-image.jpg' );
103-
self::$attached_to_draft = get_post( $attached_draft_id );
99+
update_post_meta( self::$attached_to_draft->ID, '_wp_attached_file', '2025/01/draft-attached-image.jpg' );
104100
}
105101

106102
/**

0 commit comments

Comments
 (0)