diff --git a/tests/phpunit/tests/theme/getHeaderVideoSettings.php b/tests/phpunit/tests/theme/getHeaderVideoSettings.php new file mode 100644 index 0000000000000..1a5653d69fa98 --- /dev/null +++ b/tests/phpunit/tests/theme/getHeaderVideoSettings.php @@ -0,0 +1,56 @@ +assertSame( $expected_mime, $settings['mimeType'], 'MIME type does not match expected player type.' ); + if ( empty( $video_url ) ) { + $this->assertFalse( $settings['videoUrl'], 'Video URL should be false when no video URL is configured.' ); + } else { + $this->assertSame( set_url_scheme( $video_url ), $settings['videoUrl'], 'Video URL should match input URL with current scheme.' ); + } + } + + /** + * Data provider for video URL to MIME type resolution. + * + * @return array + */ + public static function data_video_url_mime_types() { + return array( + 'youtube watch URL' => array( 'https://www.youtube.com/watch?v=1234567890', 'video/x-youtube' ), + 'youtube watch URL without www' => array( 'https://youtube.com/watch?v=1234567890', 'video/x-youtube' ), + 'youtube short URL' => array( 'https://youtu.be/1234567890', 'video/x-youtube' ), + 'direct mp4 video file' => array( 'https://example.com/header-video.mp4', 'video/mp4' ), + 'direct webm video file' => array( 'https://example.com/header-video.webm', 'video/webm' ), + 'direct mov video file' => array( 'https://example.com/header-video.mov', 'video/quicktime' ), + 'unrecognized file extension' => array( 'https://example.com/header.xyz', '' ), + 'empty video URL' => array( '', '' ), + ); + } +}