Skip to content

Commit da34a01

Browse files
committed
minor #19786 [Testing] Update nullable types (smnandre)
This PR was merged into the 5.4 branch. Discussion ---------- [Testing] Update nullable types The Symfony codebase as been recently updated to replace implicit nullable types with explicit ones, but i think the code shown in documentation (method signatures or examples) has not been updated at the same time. This PR is just a small "example" of what's to be updated on the Testing page How do you think we should handle this ? Create a "meta-issue" and split the work by component ? Commits ------- c77994d [Testing] Update nullable types
2 parents 7d7a2f9 + c77994d commit da34a01

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

testing.rst

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ The full signature of the ``request()`` method is::
606606
array $parameters = [],
607607
array $files = [],
608608
array $server = [],
609-
string $content = null,
609+
?string $content = null,
610610
bool $changeHistory = true
611611
): Crawler
612612

@@ -1007,18 +1007,18 @@ Response Assertions
10071007
Asserts that the response was successful (HTTP status is 2xx).
10081008
``assertResponseStatusCodeSame(int $expectedCode, string $message = '')``
10091009
Asserts a specific HTTP status code.
1010-
``assertResponseRedirects(string $expectedLocation = null, int $expectedCode = null, string $message = '')``
1010+
``assertResponseRedirects(?string $expectedLocation = null, ?int $expectedCode = null, string $message = '')``
10111011
Asserts the response is a redirect response (optionally, you can check
10121012
the target location and status code).
10131013
``assertResponseHasHeader(string $headerName, string $message = '')``/``assertResponseNotHasHeader(string $headerName, string $message = '')``
10141014
Asserts the given header is (not) available on the response, e.g. ``assertResponseHasHeader('content-type');``.
10151015
``assertResponseHeaderSame(string $headerName, string $expectedValue, string $message = '')``/``assertResponseHeaderNotSame(string $headerName, string $expectedValue, string $message = '')``
10161016
Asserts the given header does (not) contain the expected value on the
10171017
response, e.g. ``assertResponseHeaderSame('content-type', 'application/octet-stream');``.
1018-
``assertResponseHasCookie(string $name, string $path = '/', string $domain = null, string $message = '')``/``assertResponseNotHasCookie(string $name, string $path = '/', string $domain = null, string $message = '')``
1018+
``assertResponseHasCookie(string $name, string $path = '/', ?string $domain = null, string $message = '')``/``assertResponseNotHasCookie(string $name, string $path = '/', ?string $domain = null, string $message = '')``
10191019
Asserts the given cookie is present in the response (optionally
10201020
checking for a specific cookie path or domain).
1021-
``assertResponseCookieValueSame(string $name, string $expectedValue, string $path = '/', string $domain = null, string $message = '')``
1021+
``assertResponseCookieValueSame(string $name, string $expectedValue, string $path = '/', ?string $domain = null, string $message = '')``
10221022
Asserts the given cookie is present and set to the expected value.
10231023
``assertResponseFormatSame(?string $expectedFormat, string $message = '')``
10241024
Asserts the response format returned by the
@@ -1047,10 +1047,10 @@ Request Assertions
10471047
Browser Assertions
10481048
..................
10491049

1050-
``assertBrowserHasCookie(string $name, string $path = '/', string $domain = null, string $message = '')``/``assertBrowserNotHasCookie(string $name, string $path = '/', string $domain = null, string $message = '')``
1050+
``assertBrowserHasCookie(string $name, string $path = '/', ?string $domain = null, string $message = '')``/``assertBrowserNotHasCookie(string $name, string $path = '/', ?string $domain = null, string $message = '')``
10511051
Asserts that the test Client does (not) have the given cookie set
10521052
(meaning, the cookie was set by any response in the test).
1053-
``assertBrowserCookieValueSame(string $name, string $expectedValue, string $path = '/', string $domain = null, string $message = '')``
1053+
``assertBrowserCookieValueSame(string $name, string $expectedValue, string $path = '/', ?string $domain = null, string $message = '')``
10541054
Asserts the given cookie in the test Client is set to the expected
10551055
value.
10561056
``assertThatForClient(Constraint $constraint, string $message = '')``
@@ -1108,18 +1108,18 @@ Mailer Assertions
11081108
Starting from Symfony 5.1, the following assertions no longer require to make
11091109
a request with the ``Client`` in a test case extending the ``WebTestCase`` class.
11101110

1111-
``assertEmailCount(int $count, string $transport = null, string $message = '')``
1111+
``assertEmailCount(int $count, ?string $transport = null, string $message = '')``
11121112
Asserts that the expected number of emails was sent.
1113-
``assertQueuedEmailCount(int $count, string $transport = null, string $message = '')``
1113+
``assertQueuedEmailCount(int $count, ?string $transport = null, string $message = '')``
11141114
Asserts that the expected number of emails was queued (e.g. using the
11151115
Messenger component).
11161116
``assertEmailIsQueued(MessageEvent $event, string $message = '')``/``assertEmailIsNotQueued(MessageEvent $event, string $message = '')``
11171117
Asserts that the given mailer event is (not) queued. Use
1118-
``getMailerEvent(int $index = 0, string $transport = null)`` to
1118+
``getMailerEvent(int $index = 0, ?string $transport = null)`` to
11191119
retrieve a mailer event by index.
11201120
``assertEmailAttachmentCount(RawMessage $email, int $count, string $message = '')``
11211121
Asserts that the given email has the expected number of attachments. Use
1122-
``getMailerMessage(int $index = 0, string $transport = null)`` to
1122+
``getMailerMessage(int $index = 0, ?string $transport = null)`` to
11231123
retrieve a specific email by index.
11241124
``assertEmailTextBodyContains(RawMessage $email, string $text, string $message = '')``/``assertEmailTextBodyNotContains(RawMessage $email, string $text, string $message = '')``
11251125
Asserts that the text body of the given email does (not) contain the

0 commit comments

Comments
 (0)