@@ -3348,6 +3348,7 @@ public function test_sideload_scaled_unique_filename_conflict() {
33483348 * Tests that the finalize endpoint triggers wp_generate_attachment_metadata.
33493349 *
33503350 * @ticket 62243
3351+ * @covers WP_REST_Attachments_Controller::finalize_item
33513352 * @requires function imagejpeg
33523353 */
33533354 public function test_finalize_item (): void {
@@ -3373,6 +3374,7 @@ function ( array $metadata, int $id, string $context ) use ( &$filter_metadata,
33733374 $ filter_metadata = $ metadata ;
33743375 $ filter_id = $ id ;
33753376 $ filter_context = $ context ;
3377+ $ metadata ['foo ' ] = 'bar ' ;
33763378 return $ metadata ;
33773379 },
33783380 10 ,
@@ -3388,12 +3390,17 @@ function ( array $metadata, int $id, string $context ) use ( &$filter_metadata,
33883390 $ this ->assertStringContainsString ( 'canola ' , $ filter_metadata ['file ' ], 'Expected the canola image to have been had its metadata updated. ' );
33893391 $ this ->assertSame ( $ attachment_id , $ filter_id , 'Expected the post ID to be passed to the filter. ' );
33903392 $ this ->assertSame ( 'update ' , $ filter_context , 'Filter context should be "update". ' );
3393+ $ resulting_metadata = wp_get_attachment_metadata ( $ attachment_id );
3394+ $ this ->assertIsArray ( $ resulting_metadata );
3395+ $ this ->assertArrayHasKey ( 'foo ' , $ resulting_metadata , 'Expected new metadata key to have been added. ' );
3396+ $ this ->assertSame ( 'bar ' , $ resulting_metadata ['foo ' ], 'Expected filtered metadata to be updated. ' );
33913397 }
33923398
33933399 /**
33943400 * Tests that the finalize endpoint requires authentication.
33953401 *
33963402 * @ticket 62243
3403+ * @covers WP_REST_Attachments_Controller::finalize_item
33973404 * @requires function imagejpeg
33983405 */
33993406 public function test_finalize_item_requires_auth (): void {
@@ -3420,6 +3427,7 @@ public function test_finalize_item_requires_auth(): void {
34203427 * Tests that the finalize endpoint returns error for invalid attachment ID.
34213428 *
34223429 * @ticket 62243
3430+ * @covers WP_REST_Attachments_Controller::finalize_item
34233431 */
34243432 public function test_finalize_item_invalid_id (): void {
34253433 wp_set_current_user ( self ::$ author_id );
0 commit comments