Skip to content

Commit 80dd4df

Browse files
committed
Adding messages to asserts
1 parent 47c1ae6 commit 80dd4df

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

tests/phpunit/tests/post/wpUpdatePost.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ public function test_update_invalid_post_id() {
107107

108108
$post['ID'] = 123456789;
109109

110-
$this->assertSame( 0, wp_update_post( $post ) );
110+
$this->assertSame( 0, wp_update_post( $post ), 'wp_update_post should return 0 for invalid post ID.' );
111111

112-
$this->assertInstanceOf( 'WP_Error', wp_update_post( $post, true ) );
112+
$this->assertInstanceOf( 'WP_Error', wp_update_post( $post, true ), 'wp_update_post should return WP_Error for invalid post ID when $wp_error is true.' );
113113
}
114114

115115
/**
@@ -135,12 +135,12 @@ public function test_update_post_should_only_modify_post_tags_if_different_tags_
135135
$post = get_post( $post_id );
136136

137137
$tags = wp_get_post_tags( $post->ID, array( 'fields' => 'ids' ) );
138-
$this->assertSameSets( array( $tag_1['term_id'], $tag_2['term_id'] ), $tags );
138+
$this->assertSameSets( array( $tag_1['term_id'], $tag_2['term_id'] ), $tags, 'Post tags should match the initially assigned tags.' );
139139

140140
wp_update_post( $post );
141141

142142
$tags = wp_get_post_tags( $post->ID, array( 'fields' => 'ids' ) );
143-
$this->assertSameSets( array( $tag_1['term_id'], $tag_2['term_id'] ), $tags );
143+
$this->assertSameSets( array( $tag_1['term_id'], $tag_2['term_id'] ), $tags, 'Post tags should not change if tags_input is not provided.' );
144144

145145
wp_update_post(
146146
array(
@@ -150,7 +150,7 @@ public function test_update_post_should_only_modify_post_tags_if_different_tags_
150150
);
151151

152152
$tags = wp_get_post_tags( $post->ID, array( 'fields' => 'ids' ) );
153-
$this->assertSameSets( array( $tag_2['term_id'], $tag_3['term_id'] ), $tags );
153+
$this->assertSameSets( array( $tag_2['term_id'], $tag_3['term_id'] ), $tags, 'Post tags should be updated if different tags_input is provided.' );
154154
}
155155

156156
/**
@@ -167,8 +167,8 @@ public function test_wp_update_post_with_content_filtering() {
167167
)
168168
);
169169
$post = get_post( $post_id );
170-
$this->assertSame( '<script>Test</script>', $post->post_title );
171-
$this->assertSame( 'draft', $post->post_status );
170+
$this->assertSame( '<script>Test</script>', $post->post_title, 'Post title should not be filtered without content filtering.' );
171+
$this->assertSame( 'draft', $post->post_status, 'Post status should be draft without content filtering.' );
172172

173173
kses_init_filters();
174174

@@ -182,7 +182,7 @@ public function test_wp_update_post_with_content_filtering() {
182182
kses_remove_filters();
183183

184184
$post = get_post( $post->ID );
185-
$this->assertSame( 'Test', $post->post_title );
185+
$this->assertSame( 'Test', $post->post_title, 'Post title should be filtered with content filtering.' );
186186
}
187187

188188
/**
@@ -214,8 +214,8 @@ public function test_update_post_preserves_date_for_future_posts( $initial_statu
214214
wp_update_post( $update_data );
215215
$updated_post = get_post( $post_id );
216216

217-
$this->assertSame( $future_date, $updated_post->post_date );
218-
$this->assertSame( $expected_status, $updated_post->post_status );
217+
$this->assertSame( $future_date, $updated_post->post_date, 'Post date should be preserved when updating to future status.' );
218+
$this->assertSame( $expected_status, $updated_post->post_status, "Post status should be '{$expected_status}' after update." );
219219
}
220220

221221
/**

0 commit comments

Comments
 (0)