Skip to content

Commit 1f4336d

Browse files
Merge branch '6.4' into 7.1
* 6.4: [DoctrineBridge] Fix the `LockStoreSchemaListener` add German translations for the Week constraint messages sync Week constraint messages translations [Validator] Add `D` regex modifier in relevant validators [Validator] Add French translation for the `Week` constraint skip transient Redis integration tests on AppVeyor reject malformed URLs with a meaningful exception [Mime] Add tests on constraints
2 parents dfffe58 + 0a96d33 commit 1f4336d

File tree

86 files changed

+1335
-71
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+1335
-71
lines changed

src/Symfony/Bridge/Doctrine/SchemaListener/LockStoreSchemaListener.php

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Bridge\Doctrine\SchemaListener;
1313

1414
use Doctrine\ORM\Tools\Event\GenerateSchemaEventArgs;
15-
use Symfony\Component\Lock\Exception\InvalidArgumentException;
1615
use Symfony\Component\Lock\PersistingStoreInterface;
1716
use Symfony\Component\Lock\Store\DoctrineDbalStore;
1817

@@ -30,20 +29,12 @@ public function postGenerateSchema(GenerateSchemaEventArgs $event): void
3029
{
3130
$connection = $event->getEntityManager()->getConnection();
3231

33-
$storesIterator = new \ArrayIterator($this->stores);
34-
while ($storesIterator->valid()) {
35-
try {
36-
$store = $storesIterator->current();
37-
if (!$store instanceof DoctrineDbalStore) {
38-
continue;
39-
}
40-
41-
$store->configureSchema($event->getSchema(), $this->getIsSameDatabaseChecker($connection));
42-
} catch (InvalidArgumentException) {
43-
// no-op
32+
foreach ($this->stores as $store) {
33+
if (!$store instanceof DoctrineDbalStore) {
34+
continue;
4435
}
4536

46-
$storesIterator->next();
37+
$store->configureSchema($event->getSchema(), $this->getIsSameDatabaseChecker($connection));
4738
}
4839
}
4940
}

src/Symfony/Bridge/Doctrine/Tests/SchemaListener/LockStoreSchemaListenerTest.php

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use Doctrine\ORM\Tools\Event\GenerateSchemaEventArgs;
1818
use PHPUnit\Framework\TestCase;
1919
use Symfony\Bridge\Doctrine\SchemaListener\LockStoreSchemaListener;
20-
use Symfony\Component\Lock\Exception\InvalidArgumentException;
2120
use Symfony\Component\Lock\Store\DoctrineDbalStore;
2221

2322
class LockStoreSchemaListenerTest extends TestCase
@@ -37,23 +36,7 @@ public function testPostGenerateSchemaLockPdo()
3736
->method('configureSchema')
3837
->with($schema, fn () => true);
3938

40-
$subscriber = new LockStoreSchemaListener([$lockStore]);
41-
$subscriber->postGenerateSchema($event);
42-
}
43-
44-
public function testPostGenerateSchemaWithInvalidLockStore()
45-
{
46-
$entityManager = $this->createMock(EntityManagerInterface::class);
47-
$entityManager->expects($this->once())
48-
->method('getConnection')
49-
->willReturn($this->createMock(Connection::class));
50-
$event = new GenerateSchemaEventArgs($entityManager, new Schema());
51-
52-
$subscriber = new LockStoreSchemaListener((static function (): \Generator {
53-
yield $this->createMock(DoctrineDbalStore::class);
54-
55-
throw new InvalidArgumentException('Unsupported Connection');
56-
})());
39+
$subscriber = new LockStoreSchemaListener((static fn () => yield $lockStore)());
5740
$subscriber->postGenerateSchema($event);
5841
}
5942
}

src/Symfony/Component/HttpClient/HttpClientTrait.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,8 @@ private static function jsonEncode(mixed $value, ?int $flags = null, int $maxDep
557557
*/
558558
private static function resolveUrl(array $url, ?array $base, array $queryDefaults = []): array
559559
{
560+
$givenUrl = $url;
561+
560562
if (null !== $base && '' === ($base['scheme'] ?? '').($base['authority'] ?? '')) {
561563
throw new InvalidArgumentException(sprintf('Invalid "base_uri" option: host or scheme is missing in "%s".', implode('', $base)));
562564
}
@@ -610,6 +612,10 @@ private static function resolveUrl(array $url, ?array $base, array $queryDefault
610612
$url['query'] = null;
611613
}
612614

615+
if (null !== $url['scheme'] && null === $url['authority']) {
616+
throw new InvalidArgumentException(\sprintf('Invalid URL: host is missing in "%s".', implode('', $givenUrl)));
617+
}
618+
613619
return $url;
614620
}
615621

src/Symfony/Component/HttpClient/Tests/HttpClientTestCase.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\HttpClient\Tests;
1313

1414
use Symfony\Component\HttpClient\Exception\ClientException;
15+
use Symfony\Component\HttpClient\Exception\InvalidArgumentException;
1516
use Symfony\Component\HttpClient\Exception\TransportException;
1617
use Symfony\Component\HttpClient\Internal\ClientState;
1718
use Symfony\Component\HttpClient\Response\StreamWrapper;
@@ -456,6 +457,16 @@ public function testNullBody()
456457
$this->expectNotToPerformAssertions();
457458
}
458459

460+
public function testMisspelledScheme()
461+
{
462+
$httpClient = $this->getHttpClient(__FUNCTION__);
463+
464+
$this->expectException(InvalidArgumentException::class);
465+
$this->expectExceptionMessage('Invalid URL: host is missing in "http:/localhost:8057/".');
466+
467+
$httpClient->request('GET', 'http:/localhost:8057/');
468+
}
469+
459470
/**
460471
* @dataProvider getRedirectWithAuthTests
461472
*/

src/Symfony/Component/HttpClient/Tests/HttpClientTraitTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ public function testResolveUrl(string $base, string $url, string $expected)
175175
public static function provideResolveUrl(): array
176176
{
177177
return [
178-
[self::RFC3986_BASE, 'http:h', 'http:h'],
179178
[self::RFC3986_BASE, 'g', 'http://a/b/c/g'],
180179
[self::RFC3986_BASE, './g', 'http://a/b/c/g'],
181180
[self::RFC3986_BASE, 'g/', 'http://a/b/c/g/'],
@@ -229,7 +228,6 @@ public static function provideResolveUrl(): array
229228
['http://u:p@a/b/c/d;p?q', '.', 'http://u:p@a/b/c/'],
230229
// path ending with slash or no slash at all
231230
['http://a/b/c/d/', 'e', 'http://a/b/c/d/e'],
232-
['http:no-slash', 'e', 'http:e'],
233231
// falsey relative parts
234232
[self::RFC3986_BASE, '//0', 'http://0/'],
235233
[self::RFC3986_BASE, '0', 'http://a/b/c/0'],

src/Symfony/Component/Messenger/Bridge/Redis/Tests/Transport/RedisExtIntegrationTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,9 @@ public function testJsonError()
353353
}
354354
}
355355

356+
/**
357+
* @group transient-on-windows
358+
*/
356359
public function testGetNonBlocking()
357360
{
358361
$redis = $this->createRedisClient();
@@ -388,6 +391,9 @@ public function testGetAfterReject()
388391
}
389392
}
390393

394+
/**
395+
* @group transient-on-windows
396+
*/
391397
public function testItProperlyHandlesEmptyMessages()
392398
{
393399
$redisReceiver = new RedisReceiver($this->connection, new Serializer());

src/Symfony/Component/Mime/Tests/AddressTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ public function testCreate()
4343
$this->assertEquals($a, Address::create('fabien@symfony.com'));
4444
}
4545

46+
public function testCreateWithInvalidFormat()
47+
{
48+
$this->expectException(InvalidArgumentException::class);
49+
$this->expectExceptionMessage('Could not parse "<fabien@symfony" to a "Symfony\Component\Mime\Address" instance.');
50+
51+
Address::create('<fabien@symfony');
52+
}
53+
4654
/**
4755
* @dataProvider fromStringProvider
4856
*/

src/Symfony/Component/Mime/Tests/Encoder/IdnAddressEncoderTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\Component\Mime\Encoder;
12+
namespace Symfony\Component\Mime\Tests\Encoder;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\Mime\Encoder\IdnAddressEncoder;
1516

1617
class IdnAddressEncoderTest extends TestCase
1718
{
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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\Mime\Tests\Encoder;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\Mime\Encoder\QpContentEncoder;
16+
17+
class QpContentEncoderTest extends TestCase
18+
{
19+
public function testReplaceLastChar()
20+
{
21+
$encoder = new QpContentEncoder();
22+
23+
$this->assertSame('message=09', $encoder->encodeString('message'.chr(0x09)));
24+
$this->assertSame('message=20', $encoder->encodeString('message'.chr(0x20)));
25+
}
26+
}

src/Symfony/Component/Mime/Tests/MessageTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,16 @@ public function testGenerateMessageIdThrowsWhenHasFromButNoAddresses()
134134
$message->generateMessageId();
135135
}
136136

137+
public function testGenerateMessageIdThrowsWhenNeitherFromNorSenderIsPresent()
138+
{
139+
$message = new Message();
140+
141+
$this->expectException(LogicException::class);
142+
$this->expectExceptionMessage('An email must have a "From" or a "Sender" header.');
143+
144+
$message->generateMessageId();
145+
}
146+
137147
public function testToString()
138148
{
139149
$message = new Message();

0 commit comments

Comments
 (0)