for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Yiisoft\Test\Support;
use PHPUnit\Framework\Assert as PhpUnitAssert;
use PHPUnit\Framework\ExpectationFailedException;
final class Assert
{
/**
* Asserts that two strings equality ignoring line endings.
*
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws ExpectationFailedException
*/
public static function assertEqualStringsIgnoringLineEndings(
string $expected,
string $actual,
string $message = ''
): void {
$expected = self::normalizeLineEndings($expected);
$actual = self::normalizeLineEndings($actual);
PhpUnitAssert::assertEquals($expected, $actual, $message);
}
public static function assertStringContainsStringIgnoringLineEndings(
string $needle,
string $haystack,
$needle = self::normalizeLineEndings($needle);
$haystack = self::normalizeLineEndings($haystack);
PhpUnitAssert::assertStringContainsString($needle, $haystack, $message);
private static function normalizeLineEndings(string $value): string
return strtr($value, [
"\r\n" => "\n",
"\r" => "\n",
]);