From 308dd0ae53a8bbbbf2270d43667c0fe4525c6169 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 18 Jan 2023 12:58:05 +0000 Subject: [PATCH] Tests: Add unique messages to assertions for attachment filenames in `wp_mail()`. This makes the assertions more helpful, as per the [https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/#using-assertions 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. git-svn-id: https://develop.svn.wordpress.org/trunk@55087 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/pluggable/wpMail.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/phpunit/tests/pluggable/wpMail.php b/tests/phpunit/tests/pluggable/wpMail.php index 97f7922446..cc6b3df1a1 100644 --- a/tests/phpunit/tests/pluggable/wpMail.php +++ b/tests/phpunit/tests/pluggable/wpMail.php @@ -477,9 +477,9 @@ class Tests_Pluggable_wpMail extends WP_UnitTestCase { $attachments = $mailer->getAttachments(); - $this->assertTrue( $mailer->attachmentExists() ); - $this->assertSame( $attachments[0][1], $attachments[0][2] ); - $this->assertSame( $attachments[1][1], $attachments[1][2] ); + $this->assertTrue( $mailer->attachmentExists(), 'There are no attachments.' ); + $this->assertSame( $attachments[0][1], $attachments[0][2], 'The first attachment name did not match.' ); + $this->assertSame( $attachments[1][1], $attachments[1][2], 'The second attachment name did not match.' ); } /** @@ -505,9 +505,9 @@ class Tests_Pluggable_wpMail extends WP_UnitTestCase { $attachments = $mailer->getAttachments(); - $this->assertTrue( $mailer->attachmentExists() ); - $this->assertSame( 'alonac.jpg', $attachments[0][2] ); - $this->assertSame( 'selffaw.jpg', $attachments[1][2] ); + $this->assertTrue( $mailer->attachmentExists(), 'There are no attachments.' ); + $this->assertSame( 'alonac.jpg', $attachments[0][2], 'The first attachment name did not match.' ); + $this->assertSame( 'selffaw.jpg', $attachments[1][2], 'The second attachment name did not match.' ); } /**