Skip to content

Commit cb56133

Browse files
committed
Merge branch '5.0' into 5.1
* 5.0: Update testing.rst Typo Testing Update http_kernel.rst Update http_kernel.rst Typehint Testing Update cache_invalidation.rst
2 parents 147d8e6 + 0603317 commit cb56133

File tree

3 files changed

+43
-37
lines changed

3 files changed

+43
-37
lines changed

components/http_kernel.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ that system::
6565
*/
6666
public function handle(
6767
Request $request,
68-
$type = self::MASTER_REQUEST,
69-
$catch = true
68+
int $type = self::MASTER_REQUEST,
69+
bool $catch = true
7070
);
7171
}
7272

@@ -533,7 +533,7 @@ exception and create an appropriate error ``Response``.
533533
For example, to generate a 404 page, you might throw a special type of exception
534534
and then add a listener on this event that looks for this exception and
535535
creates and returns a 404 ``Response``. In fact, the HttpKernel component
536-
comes with an :class:`Symfony\\Component\\HttpKernel\\EventListener\\ExceptionListener`,
536+
comes with an :class:`Symfony\\Component\\HttpKernel\\EventListener\\ErrorListener`,
537537
which if you choose to use, will do this and more by default (see the sidebar
538538
below for more details).
539539

@@ -547,10 +547,10 @@ below for more details).
547547
There are two main listeners to ``kernel.exception`` when using the
548548
Symfony Framework.
549549

550-
**ExceptionListener in the HttpKernel Component**
550+
**ErrorListener in the HttpKernel Component**
551551

552552
The first comes core to the HttpKernel component
553-
and is called :class:`Symfony\\Component\\HttpKernel\\EventListener\\ExceptionListener`.
553+
and is called :class:`Symfony\\Component\\HttpKernel\\EventListener\\ErrorListener`.
554554
The listener has several goals:
555555

556556
1) The thrown exception is converted into a

http_cache/cache_invalidation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ to support the ``PURGE`` HTTP method::
6060

6161
class CacheKernel extends HttpCache
6262
{
63-
protected function invalidate(Request $request, $catch = false)
63+
protected function invalidate(Request $request, bool $catch = false)
6464
{
6565
if ('PURGE' !== $request->getMethod()) {
6666
return parent::invalidate($request, $catch);

testing.rst

Lines changed: 37 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ utilities used in the functional tests:
148148
Your First Functional Test
149149
~~~~~~~~~~~~~~~~~~~~~~~~~~
150150
Functional tests are PHP files that typically live in the ``tests/Controller``
151-
directory for your bundle. If you want to test the pages handled by your
151+
directory of your application. If you want to test the pages handled by your
152152
``PostController`` class, start by creating a new ``PostControllerTest.php``
153153
file that extends a special ``WebTestCase`` class.
154154

@@ -288,48 +288,54 @@ document::
288288

289289
// ...
290290

291-
// asserts that there is at least one h2 tag
292-
// with the class "subtitle"
293-
$this->assertGreaterThan(
294-
0,
295-
$crawler->filter('h2.subtitle')->count()
291+
// asserts that there is at least one h2 tag with the class "subtitle"
292+
// the third argument is an optional message shown on failed tests
293+
$this->assertGreaterThan(0, $crawler->filter('h2.subtitle')->count(),
294+
'There is at least one subtitle'
296295
);
297296

298297
// asserts that there are exactly 4 h2 tags on the page
299298
$this->assertCount(4, $crawler->filter('h2'));
300299

301300
// asserts that the "Content-Type" header is "application/json"
302-
$this->assertTrue(
303-
$client->getResponse()->headers->contains(
304-
'Content-Type',
305-
'application/json'
306-
),
307-
'the "Content-Type" header is "application/json"' // optional message shown on failure
308-
);
301+
$this->assertResponseHeaderSame('Content-Type', 'application/json');
302+
// equivalent to:
303+
$this->assertTrue($client->getResponse()->headers->contains(
304+
'Content-Type', 'application/json'
305+
));
309306

310307
// asserts that the response content contains a string
311308
$this->assertStringContainsString('foo', $client->getResponse()->getContent());
312309
// ...or matches a regex
313310
$this->assertRegExp('/foo(bar)?/', $client->getResponse()->getContent());
314311

315312
// asserts that the response status code is 2xx
316-
$this->assertTrue($client->getResponse()->isSuccessful(), 'response status is 2xx');
317-
// asserts that the response status code is 404
313+
$this->assertResponseIsSuccessful();
314+
// equivalent to:
315+
$this->assertTrue($client->getResponse()->isSuccessful());
316+
317+
// asserts that the response status code is 404 Not Found
318318
$this->assertTrue($client->getResponse()->isNotFound());
319-
// asserts a specific 200 status code
320-
$this->assertEquals(
321-
200, // or Symfony\Component\HttpFoundation\Response::HTTP_OK
322-
$client->getResponse()->getStatusCode()
323-
);
319+
320+
// asserts a specific status code
321+
$this->assertResponseStatusCodeSame(201);
322+
// HTTP status numbers are available as constants too:
323+
// e.g. 201 === Symfony\Component\HttpFoundation\Response::HTTP_CREATED
324+
// equivalent to:
325+
$this->assertEquals(201, $client->getResponse()->getStatusCode());
324326

325327
// asserts that the response is a redirect to /demo/contact
326-
$this->assertTrue(
327-
$client->getResponse()->isRedirect('/demo/contact')
328-
// if the redirection URL was generated as an absolute URL
329-
// $client->getResponse()->isRedirect('http://localhost/demo/contact')
330-
);
331-
// ...or simply check that the response is a redirect to any URL
332-
$this->assertTrue($client->getResponse()->isRedirect());
328+
$this->assertResponseRedirects('/demo/contact');
329+
// equivalent to:
330+
$this->assertTrue($client->getResponse()->isRedirect('/demo/contact'));
331+
// ...or check that the response is a redirect to any URL
332+
$this->assertResponseRedirects();
333+
334+
.. versionadded:: 4.3
335+
336+
The ``assertResponseHeaderSame()``, ``assertResponseIsSuccessful()``,
337+
``assertResponseStatusCodeSame()``, ``assertResponseRedirects()`` and other
338+
related methods were introduced in Symfony 4.3.
333339

334340
.. _testing-data-providers:
335341

@@ -393,13 +399,13 @@ returns a ``Crawler`` instance.
393399
The full signature of the ``request()`` method is::
394400

395401
request(
396-
$method,
397-
$uri,
402+
string $method,
403+
string $uri,
398404
array $parameters = [],
399405
array $files = [],
400406
array $server = [],
401-
$content = null,
402-
$changeHistory = true
407+
string $content = null,
408+
bool $changeHistory = true
403409
)
404410

405411
The ``server`` array is the raw values that you'd expect to normally

0 commit comments

Comments
 (0)