Skip to content

Commit 1f330f0

Browse files
committed
cs
1 parent 6a2ee30 commit 1f330f0

4 files changed

+71
-49
lines changed

tests/Mail/FallbackMailer.phpt

+5-3
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,11 @@ test('', function () {
4949
$onFailureCalls[] = $mailer;
5050
};
5151

52-
$e = Assert::exception(function () use ($mailer) {
53-
$mailer->send(new Message);
54-
}, FallbackMailerException::class, 'All mailers failed to send the message.');
52+
$e = Assert::exception(
53+
fn() => $mailer->send(new Message),
54+
FallbackMailerException::class,
55+
'All mailers failed to send the message.',
56+
);
5557
Assert::same([$subMailerA, $subMailerB, $subMailerA, $subMailerB, $subMailerA, $subMailerB], $onFailureCalls);
5658
Assert::count(6, $e->failures);
5759
Assert::same('Failure #1', $e->failures[0]->getMessage());

tests/Mail/Mail.dkim.invalidKey.phpt

+4-3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ $mail->addTo('Lady Jane <[email protected]>');
2626
$mail->setSubject('Hello Jane!');
2727
$mail->setBody('Příliš žluťoučký kůň');
2828

29-
Assert::exception(function () use ($signer, $mail) {
30-
$signer->generateSignedMessage($mail);
31-
}, SignException::class);
29+
Assert::exception(
30+
fn() => $signer->generateSignedMessage($mail),
31+
SignException::class,
32+
);

tests/Mail/Mail.email.errors.phpt

+45-32
Original file line numberDiff line numberDiff line change
@@ -15,51 +15,64 @@ require __DIR__ . '/../bootstrap.php';
1515

1616
$mail = new Message;
1717

18-
Assert::exception(function () use ($mail) {
19-
// From
20-
$mail->setFrom('John Doe <doe@example. com>');
21-
}, Nette\Utils\AssertionException::class, "The header 'From' expects to be email, string 'doe@example. com' given.");
18+
Assert::exception(
19+
fn() => $mail->setFrom('John Doe <doe@example. com>'),
20+
Nette\Utils\AssertionException::class,
21+
"The header 'From' expects to be email, string 'doe@example. com' given.",
22+
);
2223

2324

24-
Assert::exception(function () use ($mail) {
25-
$mail->setFrom('John Doe <>');
26-
}, Nette\Utils\AssertionException::class, "The header 'From' expects to be email, string '' given.");
25+
Assert::exception(
26+
fn() => $mail->setFrom('John Doe <>'),
27+
Nette\Utils\AssertionException::class,
28+
"The header 'From' expects to be email, string '' given.",
29+
);
2730

2831

29-
Assert::exception(function () use ($mail) {
30-
$mail->setFrom('John Doe <doe@examplecom>');
31-
}, Nette\Utils\AssertionException::class, "The header 'From' expects to be email, string 'doe@examplecom' given.");
32+
Assert::exception(
33+
fn() => $mail->setFrom('John Doe <doe@examplecom>'),
34+
Nette\Utils\AssertionException::class,
35+
"The header 'From' expects to be email, string 'doe@examplecom' given.",
36+
);
3237

3338

34-
Assert::exception(function () use ($mail) {
35-
$mail->setFrom('John Doe');
36-
}, Nette\Utils\AssertionException::class, "The header 'From' expects to be email, string 'John Doe' given.");
39+
Assert::exception(
40+
fn() => $mail->setFrom('John Doe'),
41+
Nette\Utils\AssertionException::class,
42+
"The header 'From' expects to be email, string 'John Doe' given.",
43+
);
3744

3845

39-
Assert::exception(function () use ($mail) {
40-
$mail->setFrom('doe;@examplecom');
41-
}, Nette\Utils\AssertionException::class, "The header 'From' expects to be email, string 'doe;@examplecom' given.");
46+
Assert::exception(
47+
fn() => $mail->setFrom('doe;@examplecom'),
48+
Nette\Utils\AssertionException::class,
49+
"The header 'From' expects to be email, string 'doe;@examplecom' given.",
50+
);
4251

4352

44-
Assert::exception(function () use ($mail) {
45-
// addReplyTo
46-
$mail->addReplyTo('@');
47-
}, Nette\Utils\AssertionException::class, "The header 'Reply-To' expects to be email, string '@' given.");
53+
Assert::exception(
54+
fn() => $mail->addReplyTo('@'),
55+
Nette\Utils\AssertionException::class,
56+
"The header 'Reply-To' expects to be email, string '@' given.",
57+
);
4858

4959

50-
Assert::exception(function () use ($mail) {
51-
// addTo
52-
$mail->addTo('@');
53-
}, Nette\Utils\AssertionException::class, "The header 'To' expects to be email, string '@' given.");
60+
Assert::exception(
61+
fn() => $mail->addTo('@'),
62+
Nette\Utils\AssertionException::class,
63+
"The header 'To' expects to be email, string '@' given.",
64+
);
5465

5566

56-
Assert::exception(function () use ($mail) {
57-
// addCc
58-
$mail->addCc('@');
59-
}, Nette\Utils\AssertionException::class, "The header 'Cc' expects to be email, string '@' given.");
67+
Assert::exception(
68+
fn() => $mail->addCc('@'),
69+
Nette\Utils\AssertionException::class,
70+
"The header 'Cc' expects to be email, string '@' given.",
71+
);
6072

6173

62-
Assert::exception(function () use ($mail) {
63-
// addBcc
64-
$mail->addBcc('@');
65-
}, Nette\Utils\AssertionException::class, "The header 'Bcc' expects to be email, string '@' given.");
74+
Assert::exception(
75+
fn() => $mail->addBcc('@'),
76+
Nette\Utils\AssertionException::class,
77+
"The header 'Bcc' expects to be email, string '@' given.",
78+
);

tests/Mail/Mail.headers.001.phpt

+17-11
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,20 @@ require __DIR__ . '/Mail.php';
1717

1818
$mail = new Message;
1919

20-
Assert::exception(function () use ($mail) {
21-
$mail->setHeader('', 'value');
22-
}, InvalidArgumentException::class, "Header name must be non-empty alphanumeric string, '' given.");
23-
24-
Assert::exception(function () use ($mail) {
25-
$mail->setHeader(' name', 'value');
26-
}, InvalidArgumentException::class, "Header name must be non-empty alphanumeric string, ' name' given.");
27-
28-
Assert::exception(function () use ($mail) {
29-
$mail->setHeader('n*ame', 'value');
30-
}, InvalidArgumentException::class, "Header name must be non-empty alphanumeric string, 'n*ame' given.");
20+
Assert::exception(
21+
fn() => $mail->setHeader('', 'value'),
22+
InvalidArgumentException::class,
23+
"Header name must be non-empty alphanumeric string, '' given.",
24+
);
25+
26+
Assert::exception(
27+
fn() => $mail->setHeader(' name', 'value'),
28+
InvalidArgumentException::class,
29+
"Header name must be non-empty alphanumeric string, ' name' given.",
30+
);
31+
32+
Assert::exception(
33+
fn() => $mail->setHeader('n*ame', 'value'),
34+
InvalidArgumentException::class,
35+
"Header name must be non-empty alphanumeric string, 'n*ame' given.",
36+
);

0 commit comments

Comments
 (0)