From 43c193f58be4c1e0807756bfe9b3e572528772f0 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 11 Jul 2020 23:27:51 +0000 Subject: [PATCH] Tests: Ignore EOL differences in email tests using multiline string assertions. Unix vs. Windows EOL style mismatches can cause misleading failures in tests using the heredoc syntax (`<<<`) or multiline strings as the expected result. Follow-up to [46612], [48033]. Props davidbaumwald. See #31432, #41750. git-svn-id: https://develop.svn.wordpress.org/trunk@48443 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/mail.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/phpunit/tests/mail.php b/tests/phpunit/tests/mail.php index c5897a8bad..d24d5e831a 100644 --- a/tests/phpunit/tests/mail.php +++ b/tests/phpunit/tests/mail.php @@ -80,7 +80,7 @@ class Tests_Mail extends WP_UnitTestCase { $mailer = tests_retrieve_phpmailer_instance(); // We need some better assertions here but these catch the failure for now. - $this->assertEquals( $body, $mailer->get_sent()->body ); + $this->assertEqualsIgnoreEOL( $body, $mailer->get_sent()->body ); $this->assertTrue( strpos( iconv_mime_decode_headers( ( $mailer->get_sent()->header ) )['Content-Type'][0], 'boundary="----=_Part_4892_25692638.1192452070893"' ) > 0 ); $this->assertTrue( strpos( $mailer->get_sent()->header, 'charset=' ) > 0 ); } @@ -112,7 +112,7 @@ class Tests_Mail extends WP_UnitTestCase { $this->assertEquals( 'The Carbon Guy', $mailer->get_recipient( 'cc' )->name ); $this->assertEquals( 'bcc@bcc.com', $mailer->get_recipient( 'bcc' )->address ); $this->assertEquals( 'The Blind Carbon Guy', $mailer->get_recipient( 'bcc' )->name ); - $this->assertEquals( $message . "\n", $mailer->get_sent()->body ); + $this->assertEqualsIgnoreEOL( $message . "\n", $mailer->get_sent()->body ); } /** @@ -132,7 +132,7 @@ class Tests_Mail extends WP_UnitTestCase { $this->assertEquals( 'Name', $mailer->get_recipient( 'to' )->name ); $this->assertEquals( 'another_address@different-tld.com', $mailer->get_recipient( 'to', 0, 1 )->address ); $this->assertEquals( 'Another Name', $mailer->get_recipient( 'to', 0, 1 )->name ); - $this->assertEquals( $message . "\n", $mailer->get_sent()->body ); + $this->assertEqualsIgnoreEOL( $message . "\n", $mailer->get_sent()->body ); } function test_wp_mail_multiple_to_addresses() { @@ -145,7 +145,7 @@ class Tests_Mail extends WP_UnitTestCase { $mailer = tests_retrieve_phpmailer_instance(); $this->assertEquals( 'address@tld.com', $mailer->get_recipient( 'to' )->address ); $this->assertEquals( 'another_address@different-tld.com', $mailer->get_recipient( 'to', 0, 1 )->address ); - $this->assertEquals( $message . "\n", $mailer->get_sent()->body ); + $this->assertEqualsIgnoreEOL( $message . "\n", $mailer->get_sent()->body ); } /** @@ -160,7 +160,7 @@ class Tests_Mail extends WP_UnitTestCase { $mailer = tests_retrieve_phpmailer_instance(); $this->assertEquals( 'address@tld.com', $mailer->get_recipient( 'to' )->address ); - $this->assertEquals( $message . "\n", $mailer->get_sent()->body ); + $this->assertEqualsIgnoreEOL( $message . "\n", $mailer->get_sent()->body ); } /**