From bf7d828516b7eec75827f68d0ceb5d11e0565c15 Mon Sep 17 00:00:00 2001 From: shail-mehta Date: Tue, 3 Nov 2026 16:37:50 +0000 Subject: [PATCH 1/3] Tests: Add unit coverage for `wp_exif_date2ts()`. Cover Exif Y:m:d H:i:s conversion to a unix timestamp. See #65819. --- .../admin/includes/image/wpExifDate2ts.php | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tests/phpunit/tests/admin/includes/image/wpExifDate2ts.php diff --git a/tests/phpunit/tests/admin/includes/image/wpExifDate2ts.php b/tests/phpunit/tests/admin/includes/image/wpExifDate2ts.php new file mode 100644 index 0000000000000..138b99aad1908 --- /dev/null +++ b/tests/phpunit/tests/admin/includes/image/wpExifDate2ts.php @@ -0,0 +1,21 @@ +assertSame( + strtotime( '2000-01-02 03:04:05' ), + wp_exif_date2ts( '2000:01:02 03:04:05' ) + ); + } +} From 250f24b82171773f0553874e2080c756025b0514 Mon Sep 17 00:00:00 2001 From: shail-mehta Date: Tue, 3 Nov 2026 16:42:54 +0000 Subject: [PATCH 2/3] Tests: Add unit coverage for `wp_exif_date2ts()`. Cover Exif Y:m:d H:i:s conversion to a unix timestamp. See #65819. --- .../phpunit/tests/admin/includes/image/wpExifDate2ts.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/phpunit/tests/admin/includes/image/wpExifDate2ts.php b/tests/phpunit/tests/admin/includes/image/wpExifDate2ts.php index 138b99aad1908..b5fd42f023af6 100644 --- a/tests/phpunit/tests/admin/includes/image/wpExifDate2ts.php +++ b/tests/phpunit/tests/admin/includes/image/wpExifDate2ts.php @@ -9,6 +9,15 @@ */ class Tests_Admin_Includes_Image_WpExifDate2ts extends WP_UnitTestCase { + /** + * Loads the tested file. + */ + public static function set_up_before_class() { + parent::set_up_before_class(); + + require_once ABSPATH . 'wp-admin/includes/image.php'; + } + /** * @ticket 65819 */ From 5a142f0d1e4474f183e5953d9a68324e39ad71c6 Mon Sep 17 00:00:00 2001 From: Shail Mehta Date: Tue, 3 Nov 2026 22:15:55 +0530 Subject: [PATCH 3/3] Update test for converting Exif datetime to timestamp Refactor test to accept input from data provider for Exif datetime conversion. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- .../admin/includes/image/wpExifDate2ts.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/tests/admin/includes/image/wpExifDate2ts.php b/tests/phpunit/tests/admin/includes/image/wpExifDate2ts.php index b5fd42f023af6..1abc32f0de73f 100644 --- a/tests/phpunit/tests/admin/includes/image/wpExifDate2ts.php +++ b/tests/phpunit/tests/admin/includes/image/wpExifDate2ts.php @@ -20,11 +20,26 @@ public static function set_up_before_class() { /** * @ticket 65819 + * @dataProvider data_exif_datetimes + * + * @param string $input Exif datetime to convert. */ - public function test_converts_exif_datetime_to_timestamp() { + public function test_converts_exif_datetime_to_timestamp( $input ) { $this->assertSame( strtotime( '2000-01-02 03:04:05' ), - wp_exif_date2ts( '2000:01:02 03:04:05' ) + wp_exif_date2ts( $input ) + ); + } + + /** + * Data provider for test_converts_exif_datetime_to_timestamp(). + * + * @return array + */ + public static function data_exif_datetimes() { + return array( + 'valid Exif datetime' => array( '2000:01:02 03:04:05' ), + 'surrounding whitespace' => array( " \t2000:01:02 03:04:05\r\n " ), ); } }