NormalizeBreaksTest: add extra test

... to verify the behaviour of the `PHPMailer::normalizeBreaks()` method when the `PHPMailer::$LE` property has been customized.
This commit is contained in:
jrfnl 2021-07-02 00:26:17 +02:00
parent 14d7458826
commit d6f3fea0ea
1 changed files with 22 additions and 0 deletions

View File

@ -14,6 +14,7 @@
namespace PHPMailer\Test\PHPMailer;
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\Test\TestCase as MailerTestCase;
use Yoast\PHPUnitPolyfills\TestCases\TestCase;
/**
@ -85,4 +86,25 @@ final class NormalizeBreaksTest extends TestCase
],
];
}
/**
* Test line break normalization with a custom line ending setting.
*/
public function testNormalizeBreaksWithCustomLineEnding()
{
$input = "hello\rWorld\rAgain\r";
$expected = "hello\n\rWorld\n\rAgain\n\r";
$origLE = PHPMailer::getLE();
MailerTestCase::updateStaticProperty(PHPMailer::class, 'LE', "\n\r");
$result = PHPMailer::normalizeBreaks($input);
/*
* Reset the static property *before* the assertion to ensure the reset executes
* even when the test would fail.
*/
MailerTestCase::updateStaticProperty(PHPMailer::class, 'LE', $origLE);
self::assertSame($expected, $result, 'Line break reformatting failed');
}
}