WordPress.org

Make WordPress Core

Changeset 48443


Ignore:
Timestamp:
07/11/2020 11:27:51 PM (3 months ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/mail.php

    r48033 r48443  
    8181
    8282        // We need some better assertions here but these catch the failure for now.
    83         $this->assertEquals( $body, $mailer->get_sent()->body );
     83        $this->assertEqualsIgnoreEOL( $body, $mailer->get_sent()->body );
    8484        $this->assertTrue( strpos( iconv_mime_decode_headers( ( $mailer->get_sent()->header ) )['Content-Type'][0], 'boundary="----=_Part_4892_25692638.1192452070893"' ) > 0 );
    8585        $this->assertTrue( strpos( $mailer->get_sent()->header, 'charset=' ) > 0 );
     
    113113        $this->assertEquals( 'bcc@bcc.com', $mailer->get_recipient( 'bcc' )->address );
    114114        $this->assertEquals( 'The Blind Carbon Guy', $mailer->get_recipient( 'bcc' )->name );
    115         $this->assertEquals( $message . "\n", $mailer->get_sent()->body );
     115        $this->assertEqualsIgnoreEOL( $message . "\n", $mailer->get_sent()->body );
    116116    }
    117117
     
    133133        $this->assertEquals( 'another_address@different-tld.com', $mailer->get_recipient( 'to', 0, 1 )->address );
    134134        $this->assertEquals( 'Another Name', $mailer->get_recipient( 'to', 0, 1 )->name );
    135         $this->assertEquals( $message . "\n", $mailer->get_sent()->body );
     135        $this->assertEqualsIgnoreEOL( $message . "\n", $mailer->get_sent()->body );
    136136    }
    137137
     
    146146        $this->assertEquals( 'address@tld.com', $mailer->get_recipient( 'to' )->address );
    147147        $this->assertEquals( 'another_address@different-tld.com', $mailer->get_recipient( 'to', 0, 1 )->address );
    148         $this->assertEquals( $message . "\n", $mailer->get_sent()->body );
     148        $this->assertEqualsIgnoreEOL( $message . "\n", $mailer->get_sent()->body );
    149149    }
    150150
     
    161161        $mailer = tests_retrieve_phpmailer_instance();
    162162        $this->assertEquals( 'address@tld.com', $mailer->get_recipient( 'to' )->address );
    163         $this->assertEquals( $message . "\n", $mailer->get_sent()->body );
     163        $this->assertEqualsIgnoreEOL( $message . "\n", $mailer->get_sent()->body );
    164164    }
    165165
Note: See TracChangeset for help on using the changeset viewer.