99 */
1010class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Controller_Testcase {
1111
12- protected static $ superadmin_id ;
13- protected static $ editor_id ;
14- protected static $ author_id ;
15- protected static $ contributor_id ;
16- protected static $ uploader_id ;
17- protected static $ rest_after_insert_attachment_count ;
18- protected static $ rest_insert_attachment_count ;
12+ protected static int $ superadmin_id ;
13+ protected static int $ editor_id ;
14+ protected static int $ author_id ;
15+ protected static int $ contributor_id ;
16+ protected static int $ uploader_id ;
17+ protected static int $ rest_after_insert_attachment_count ;
18+ protected static int $ rest_insert_attachment_count ;
1919
2020 /**
2121 * @var string The path to a test file.
2222 */
23- private static $ test_file ;
23+ private static string $ test_file ;
2424
2525 /**
2626 * @var string The path to a second test file.
2727 */
28- private static $ test_file2 ;
28+ private static string $ test_file2 ;
2929
3030 /**
3131 * @var string The path to the AVIF test image.
3232 */
33- private static $ test_avif_file ;
33+ private static string $ test_avif_file ;
3434
3535 /**
3636 * @var string The path to the SVG test image.
3737 */
38- private static $ test_svg_file ;
38+ private static string $ test_svg_file ;
3939
4040 /**
4141 * @var string The path to the test video.
4242 */
43- private static $ test_video_file ;
43+ private static string $ test_video_file ;
4444
4545 /**
4646 * @var string The path to the test audio.
4747 */
48- private static $ test_audio_file ;
48+ private static string $ test_audio_file ;
4949
5050 /**
5151 * @var string The path to the test RTF file.
5252 */
53- private static $ test_rtf_file ;
53+ private static string $ test_rtf_file ;
5454
5555 /**
56- * @var array The recorded posts query clauses.
56+ * @var string[] The recorded posts query clauses.
5757 */
58- protected $ posts_clauses ;
58+ protected array $ posts_clauses ;
5959
6060 public static function wpSetUpBeforeClass ( WP_UnitTest_Factory $ factory ) {
6161 self ::$ superadmin_id = $ factory ->user ->create (
@@ -3378,6 +3378,7 @@ public function test_sideload_route_includes_generate_sub_sizes_arg(): void {
33783378 $ routes = rest_get_server ()->get_routes ();
33793379 $ endpoint = $ routes ['/wp/v2/media/(?P<id>[\d]+)/sideload ' ][0 ];
33803380 $ args = $ endpoint ['args ' ];
3381+ $ this ->assertIsArray ( $ args );
33813382
33823383 $ this ->assertArrayHasKey ( 'generate_sub_sizes ' , $ args , 'Route should have generate_sub_sizes arg. ' );
33833384 $ this ->assertSame ( 'boolean ' , $ args ['generate_sub_sizes ' ]['type ' ], 'generate_sub_sizes should be a boolean. ' );
@@ -3402,9 +3403,10 @@ public function test_sideload_original_heic_writes_metadata_original(): void {
34023403 $ request = new WP_REST_Request ( 'POST ' , '/wp/v2/media ' );
34033404 $ request ->set_header ( 'Content-Type ' , 'image/jpeg ' );
34043405 $ request ->set_header ( 'Content-Disposition ' , 'attachment; filename=canola.jpg ' );
3405- $ request ->set_body ( file_get_contents ( self ::$ test_file ) );
3406+ $ request ->set_body ( ( string ) file_get_contents ( self ::$ test_file ) );
34063407 $ response = rest_get_server ()->dispatch ( $ request );
34073408 $ attachment_id = $ response ->get_data ()['id ' ];
3409+ $ this ->assertIsInt ( $ attachment_id );
34083410
34093411 $ this ->assertSame ( 201 , $ response ->get_status () );
34103412
@@ -3416,12 +3418,13 @@ public function test_sideload_original_heic_writes_metadata_original(): void {
34163418 $ request ->set_header ( 'Content-Disposition ' , 'attachment; filename=canola.heic ' );
34173419 $ request ->set_param ( 'image_size ' , 'original-heic ' );
34183420 $ request ->set_param ( 'convert_format ' , false );
3419- $ request ->set_body ( file_get_contents ( DIR_TESTDATA . '/images/test-image.heic ' ) );
3421+ $ request ->set_body ( ( string ) file_get_contents ( DIR_TESTDATA . '/images/test-image.heic ' ) );
34203422 $ response = rest_get_server ()->dispatch ( $ request );
34213423
34223424 $ this ->assertSame ( 200 , $ response ->get_status (), 'Sideloading original-heic should succeed. ' );
34233425
34243426 $ metadata = wp_get_attachment_metadata ( $ attachment_id );
3427+ $ this ->assertIsArray ( $ metadata );
34253428 $ this ->assertArrayHasKey ( 'original ' , $ metadata , "Metadata should contain 'original' for the HEIC companion. " );
34263429 $ this ->assertMatchesRegularExpression ( '/canola.*\.heic$/ ' , $ metadata ['original ' ], "Metadata 'original' should reference the HEIC filename. " );
34273430 $ this ->assertArrayNotHasKey ( 'original_image ' , $ metadata , "Metadata 'original_image' should be untouched by the HEIC sideload. " );
0 commit comments