Skip to content

Commit c3fa5c0

Browse files
Merge branch '5.4' into 6.4
* 5.4: [Console][PhpUnitBridge][VarDumper] Fix `NO_COLOR` empty value handling [Translation] Fix CSV escape char in `CsvFileLoader` on PHP >= 7.4 [DoctrineBridge] fix messenger bus dispatch inside an active transaction [HttpFoundation] Add tests for uncovered sections treat uninitialized properties referenced by property paths as null properly set up constraint options [ErrorHandler][VarDumper] Remove PHP 8.4 deprecations [Core] Fix & Enhance security arabic translation.
2 parents e36a71e + 9c375b2 commit c3fa5c0

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

Tests/InputBagTest.php

+18
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,24 @@ public function testFilterArrayWithoutArrayFlag()
161161
$bag->filter('foo', \FILTER_VALIDATE_INT);
162162
}
163163

164+
public function testAdd()
165+
{
166+
$bag = new InputBag(['foo' => 'bar']);
167+
$bag->add(['baz' => 'qux']);
168+
169+
$this->assertSame('bar', $bag->get('foo'), '->add() does not remove existing parameters');
170+
$this->assertSame('qux', $bag->get('baz'), '->add() adds new parameters');
171+
}
172+
173+
public function testReplace()
174+
{
175+
$bag = new InputBag(['foo' => 'bar']);
176+
$bag->replace(['baz' => 'qux']);
177+
178+
$this->assertNull($bag->get('foo'), '->replace() removes existing parameters');
179+
$this->assertSame('qux', $bag->get('baz'), '->replace() adds new parameters');
180+
}
181+
164182
public function testGetEnum()
165183
{
166184
$bag = new InputBag(['valid-value' => 1]);

Tests/RateLimiter/AbstractRequestRateLimiterTest.php

+29
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\HttpFoundation\Request;
1616
use Symfony\Component\RateLimiter\LimiterInterface;
17+
use Symfony\Component\RateLimiter\Policy\NoLimiter;
1718
use Symfony\Component\RateLimiter\RateLimit;
1819

1920
class AbstractRequestRateLimiterTest extends TestCase
@@ -33,6 +34,34 @@ public function testConsume(array $rateLimits, ?RateLimit $expected)
3334
$this->assertSame($expected, $rateLimiter->consume(new Request()));
3435
}
3536

37+
public function testConsumeWithoutLimiterAddsSpecialNoLimiter()
38+
{
39+
$rateLimiter = new MockAbstractRequestRateLimiter([]);
40+
41+
try {
42+
$this->assertSame(\PHP_INT_MAX, $rateLimiter->consume(new Request())->getLimit());
43+
} catch (\TypeError $error) {
44+
if (str_contains($error->getMessage(), 'RateLimit::__construct(): Argument #1 ($availableTokens) must be of type int, float given')) {
45+
$this->markTestSkipped('This test cannot be run on a version of the RateLimiter component that uses \INF instead of \PHP_INT_MAX in NoLimiter.');
46+
}
47+
48+
throw $error;
49+
}
50+
}
51+
52+
public function testResetLimiters()
53+
{
54+
$rateLimiter = new MockAbstractRequestRateLimiter([
55+
$limiter1 = $this->createMock(LimiterInterface::class),
56+
$limiter2 = $this->createMock(LimiterInterface::class),
57+
]);
58+
59+
$limiter1->expects($this->once())->method('reset');
60+
$limiter2->expects($this->once())->method('reset');
61+
62+
$rateLimiter->reset(new Request());
63+
}
64+
3665
public static function provideRateLimits()
3766
{
3867
$now = new \DateTimeImmutable();

0 commit comments

Comments
 (0)