Make WordPress Core

Changeset 55087


Ignore:
Timestamp:
01/18/2023 12:58:05 PM (17 months ago)
Author:
SergeyBiryukov
Message:

Tests: Add unique messages to assertions for attachment filenames in wp_mail().

This makes the assertions more helpful, as per the Writing PHP Tests guidelines:

All PHPUnit assertions, as well as all WordPress custom assertions, allow for a $message parameter to be passed. This message will be displayed when the assertion fails and can help immensely when debugging a test. This parameter should always be used if more than one assertion is used in a test method.

Follow-up to [55030], [55032].

Props mukesh27, costdev.
See #28407.

File:
1 edited

Legend:

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

    r55032 r55087  
    478478        $attachments = $mailer->getAttachments();
    479479
    480         $this->assertTrue( $mailer->attachmentExists() );
    481         $this->assertSame( $attachments[0][1], $attachments[0][2] );
    482         $this->assertSame( $attachments[1][1], $attachments[1][2] );
     480        $this->assertTrue( $mailer->attachmentExists(), 'There are no attachments.' );
     481        $this->assertSame( $attachments[0][1], $attachments[0][2], 'The first attachment name did not match.' );
     482        $this->assertSame( $attachments[1][1], $attachments[1][2], 'The second attachment name did not match.' );
    483483    }
    484484
     
    506506        $attachments = $mailer->getAttachments();
    507507
    508         $this->assertTrue( $mailer->attachmentExists() );
    509         $this->assertSame( 'alonac.jpg', $attachments[0][2] );
    510         $this->assertSame( 'selffaw.jpg', $attachments[1][2] );
     508        $this->assertTrue( $mailer->attachmentExists(), 'There are no attachments.' );
     509        $this->assertSame( 'alonac.jpg', $attachments[0][2], 'The first attachment name did not match.' );
     510        $this->assertSame( 'selffaw.jpg', $attachments[1][2], 'The second attachment name did not match.' );
    511511    }
    512512
Note: See TracChangeset for help on using the changeset viewer.