Make WordPress Core


Ignore:
Timestamp:
10/29/2019 02:26:41 PM (5 years ago)
Author:
SergeyBiryukov
Message:

Build/Test Tools: Ignore EOL differences in 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.

Fixes #31432. See #42594, #47411.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/abstract-testcase.php

    r46586 r46612  
    634634    public function assertDiscardWhitespace( $expected, $actual ) {
    635635        $this->assertEquals( preg_replace( '/\s*/', '', $expected ), preg_replace( '/\s*/', '', $actual ) );
     636    }
     637
     638    /**
     639     * Asserts that two values are equal, with EOL differences discarded.
     640     *
     641     * @since 5.4.0
     642     *
     643     * @param string $expected The expected value.
     644     * @param string $actual   The actual value.
     645     */
     646    public function assertEqualsIgnoreEOL( $expected, $actual ) {
     647        $this->assertEquals( str_replace( "\r\n", "\n", $expected ), str_replace( "\r\n", "\n", $actual ) );
    636648    }
    637649
Note: See TracChangeset for help on using the changeset viewer.