mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
Tests: Ignore EOL differences in some 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 [48466], [50995], [51079]. See #52625. git-svn-id: https://develop.svn.wordpress.org/trunk@51135 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -660,12 +660,27 @@ abstract class WP_UnitTestCase_Base extends PHPUnit\Framework\TestCase {
|
||||
* Asserts that two values have the same type and value, with EOL differences discarded.
|
||||
*
|
||||
* @since 5.6.0
|
||||
* @since 5.8.0 Added support for nested arrays.
|
||||
*
|
||||
* @param string $expected The expected value.
|
||||
* @param string $actual The actual value.
|
||||
* @param string|array $expected The expected value.
|
||||
* @param string|array $actual The actual value.
|
||||
*/
|
||||
public function assertSameIgnoreEOL( $expected, $actual ) {
|
||||
$this->assertSame( str_replace( "\r\n", "\n", $expected ), str_replace( "\r\n", "\n", $actual ) );
|
||||
$expected = map_deep(
|
||||
$expected,
|
||||
function ( $value ) {
|
||||
return str_replace( "\r\n", "\n", $value );
|
||||
}
|
||||
);
|
||||
|
||||
$actual = map_deep(
|
||||
$actual,
|
||||
function ( $value ) {
|
||||
return str_replace( "\r\n", "\n", $value );
|
||||
}
|
||||
);
|
||||
|
||||
$this->assertSame( $expected, $actual );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user