Skip to content

Commit 96c72fb

Browse files
committed
Mail: Improve tests for mail embeds
Use a dataProvider to ensure that embeds works with multiple different shaped arrays. Follow-up to [60698]. Props sirlouen, dmsnell, jorbin. Fixes #28059. git-svn-id: https://develop.svn.wordpress.org/trunk@61025 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 7b61018 commit 96c72fb

File tree

1 file changed

+36
-7
lines changed

1 file changed

+36
-7
lines changed

tests/phpunit/tests/pluggable/wpMail.php

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -556,14 +556,12 @@ public function test_wp_mail_resets_properties() {
556556
* Tests that wp_mail() can send embedded images.
557557
*
558558
* @ticket 28059
559+
*
560+
* @dataProvider data_wp_mail_can_send_embedded_images
561+
*
562+
* @param string[] $embeds The embeds to send.
559563
*/
560-
public function test_wp_mail_can_send_embedded_images() {
561-
$embeds = array(
562-
'canola' => DIR_TESTDATA . '/images/canola.jpg',
563-
DIR_TESTDATA . '/images/test-image-2.gif',
564-
DIR_TESTDATA . '/images/avif-lossy.avif',
565-
);
566-
564+
public function test_wp_mail_can_send_embedded_images( $embeds ) {
567565
$message = '';
568566
foreach ( $embeds as $key => $path ) {
569567
$message .= '<p><img src="cid:' . $key . '" alt="" /></p>';
@@ -590,6 +588,37 @@ public function test_wp_mail_can_send_embedded_images() {
590588
}
591589
}
592590

591+
/**
592+
* Data provider for test_wp_mail_can_send_embedded_images().
593+
*
594+
* @return array
595+
*/
596+
public static function data_wp_mail_can_send_embedded_images() {
597+
return array(
598+
'Mixed Array Embeds' => array(
599+
'embeds' => array(
600+
'canola' => DIR_TESTDATA . '/images/canola.jpg',
601+
DIR_TESTDATA . '/images/test-image-2.gif',
602+
DIR_TESTDATA . '/images/avif-lossy.avif',
603+
),
604+
),
605+
'Associative Array Embeds' => array(
606+
'embeds' => array(
607+
'canola' => DIR_TESTDATA . '/images/canola.jpg',
608+
'test-image-2' => DIR_TESTDATA . '/images/test-image-2.gif',
609+
'avif-lossy' => DIR_TESTDATA . '/images/avif-lossy.avif',
610+
),
611+
),
612+
'Indexed Array Embeds' => array(
613+
'embeds' => array(
614+
DIR_TESTDATA . '/images/canola.jpg',
615+
DIR_TESTDATA . '/images/test-image-2.gif',
616+
DIR_TESTDATA . '/images/avif-lossy.avif',
617+
),
618+
),
619+
);
620+
}
621+
593622
/**
594623
* Tests that wp_mail() can send embedded images as a multiple line string.
595624
*

0 commit comments

Comments
 (0)