Make WordPress Core

Changeset 61025


Ignore:
Timestamp:
10/21/2025 12:45:03 PM (11 months ago)
Author:
jorbin
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/pluggable/wpMail.php

    r61010 r61025  
    557557         *
    558558         * @ticket 28059
    559          */
    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 
     559         *
     560         * @dataProvider data_wp_mail_can_send_embedded_images
     561         *
     562         * @param string[] $embeds The embeds to send.
     563         */
     564        public function test_wp_mail_can_send_embedded_images( $embeds ) {
    567565                $message = '';
    568566                foreach ( $embeds as $key => $path ) {
     
    592590
    593591        /**
     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
     622        /**
    594623         * Tests that wp_mail() can send embedded images as a multiple line string.
    595624         *
Note: See TracChangeset for help on using the changeset viewer.