Skip to content

Commit 00b52ff

Browse files
Merge branch '5.4' into 6.0
* 5.4: (26 commits) [Dotenv] Fix testBootEnv() to start from a fresh context fix tests relax expected exception message for forward-compatibility with 5.4 fix expected exception messages after changes made in Definition class [DependencyInjection] show class name on DI errors skip command completion tests with older Symfony Console versions Use GitHub issue form templates Fix CS add ResponseIsUnprocessable Add missing translations for Persian (fa) skip command completion tests with older Symfony Console versions prevent issues with timezones and DST by using only UNIX timestamps Add the missing translations for Bahasa Indonesia (id) [Finder] Fix .gitignore infinite loop Update README.md fix messenger DI dependency for registerAttributeForAutoconfiguration [Messenger] Autoconfigurable attributes Fix deprecations on PHP 8.2 [Dotenv] Fix testLoadEnv() .env.dist isolation Since 5.0, throws \UnexpectedValueException has been removed. ...
2 parents bc0f062 + 631a6ae commit 00b52ff

File tree

3 files changed

+83
-2
lines changed

3 files changed

+83
-2
lines changed

Response.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,6 @@ public function send(): static
387387
* Sets the response content.
388388
*
389389
* @return $this
390-
*
391-
* @throws \UnexpectedValueException
392390
*/
393391
public function setContent(?string $content): static
394392
{
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\HttpFoundation\Test\Constraint;
13+
14+
use PHPUnit\Framework\Constraint\Constraint;
15+
use Symfony\Component\HttpFoundation\Response;
16+
17+
final class ResponseIsUnprocessable extends Constraint
18+
{
19+
/**
20+
* {@inheritdoc}
21+
*/
22+
public function toString(): string
23+
{
24+
return 'is unprocessable';
25+
}
26+
27+
/**
28+
* @param Response $other
29+
*
30+
* {@inheritdoc}
31+
*/
32+
protected function matches($other): bool
33+
{
34+
return Response::HTTP_UNPROCESSABLE_ENTITY === $other->getStatusCode();
35+
}
36+
37+
/**
38+
* @param Response $other
39+
*
40+
* {@inheritdoc}
41+
*/
42+
protected function failureDescription($other): string
43+
{
44+
return 'the Response '.$this->toString();
45+
}
46+
47+
/**
48+
* @param Response $other
49+
*
50+
* {@inheritdoc}
51+
*/
52+
protected function additionalFailureDescription($other): string
53+
{
54+
return (string) $other;
55+
}
56+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\HttpFoundation\Tests\Test\Constraint;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\HttpFoundation\Response;
16+
use Symfony\Component\HttpFoundation\Test\Constraint\ResponseIsUnprocessable;
17+
18+
class ResponseIsUnprocessableTest extends TestCase
19+
{
20+
public function testConstraint()
21+
{
22+
$constraint = new ResponseIsUnprocessable();
23+
24+
$this->assertTrue($constraint->evaluate(new Response('', 422), '', true));
25+
$this->assertFalse($constraint->evaluate(new Response(), '', true));
26+
}
27+
}

0 commit comments

Comments
 (0)