Skip to content

Commit 7adba28

Browse files
committed
Merge branch '5.4' into 6.4
* 5.4: [PropertyInfo] Update DoctrineExtractor for new DBAL 4 BIGINT type Update security.nl.xlf [Validator] IBAN Check digits should always between 2 and 98 [Security] Populate translations for trans-unit 20 add missing plural translation messages filter out empty HTTP header parts [String] Fix folded in compat mode Remove calls to `getMockForAbstractClass()` [ErrorHandler] Do not call xdebug_get_function_stack() with xdebug >= 3.0 when not in develop mode [Serializer] Fix type for missing property add test for JSON response with null as content [Filesystem] Fix dumpFile `stat failed` error hitting custom handler Remove calls to `TestCase::iniSet()` and calls to deprecated methods of `MockBuilder` [PhpUnitBridge] Fix `DeprecationErrorHandler` with PhpUnit 10
2 parents e4bd593 + 6284bb5 commit 7adba28

File tree

111 files changed

+682
-180
lines changed

Some content is hidden

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

111 files changed

+682
-180
lines changed

.github/workflows/integration-tests.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,18 @@ jobs:
192192
./phpunit install
193193
echo "::endgroup::"
194194
195+
- name: Check for changes in translation files
196+
id: changed-translation-files
197+
run: |
198+
echo 'changed='$((git diff --quiet HEAD~1 HEAD -- 'src/**/Resources/translations/*.xlf' || (echo 'true' && exit 1)) && echo 'false') >> $GITHUB_OUTPUT
199+
200+
- name: Check Translation Status
201+
if: steps.changed-translation-files.outputs.changed == 'true'
202+
run: |
203+
php src/Symfony/Component/Translation/Resources/bin/translation-status.php -v
204+
php .github/sync-translations.php
205+
git diff --exit-code src/ || (echo '::error::Run "php .github/sync-translations.php" to fix XLIFF files.' && exit 1)
206+
195207
- name: Run tests
196208
run: ./phpunit --group integration -v
197209
env:
@@ -216,15 +228,3 @@ jobs:
216228
# docker run --rm -e COMPOSER_ROOT_VERSION -v $(pwd):/app -v $(which composer):/usr/local/bin/composer -v $(which vulcain):/usr/local/bin/vulcain -w /app php:8.1-alpine ./phpunit src/Symfony/Component/HttpClient/Tests/CurlHttpClientTest.php --filter testHttp2Push
217229
# sudo rm -rf .phpunit
218230
# [ -d .phpunit.bak ] && mv .phpunit.bak .phpunit
219-
220-
- name: Check for changes in translation files
221-
id: changed-translation-files
222-
run: |
223-
echo 'changed='$((git diff --quiet HEAD~1 HEAD -- 'src/**/Resources/translations/*.xlf' || (echo 'true' && exit 1)) && echo 'false') >> $GITHUB_OUTPUT
224-
225-
- name: Check Translation Status
226-
if: steps.changed-translation-files.outputs.changed == 'true'
227-
run: |
228-
php src/Symfony/Component/Translation/Resources/bin/translation-status.php -v
229-
php .github/sync-translations.php
230-
git diff --exit-code src/ || (echo '::error::Run "php .github/sync-translations.php" to fix XLIFF files.' && exit 1)

src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php

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

1414
use Doctrine\Common\Collections\Collection;
15+
use Doctrine\DBAL\Types\BigIntType;
1516
use Doctrine\DBAL\Types\Types;
1617
use Doctrine\ORM\EntityManagerInterface;
1718
use Doctrine\ORM\Mapping\AssociationMapping;
@@ -132,6 +133,15 @@ public function getTypes(string $class, string $property, array $context = []):
132133
}
133134

134135
$nullable = $metadata instanceof ClassMetadata && $metadata->isNullable($property);
136+
137+
// DBAL 4 has a special fallback strategy for BINGINT (int -> string)
138+
if (Types::BIGINT === $typeOfField && !method_exists(BigIntType::class, 'getName')) {
139+
return [
140+
new Type(Type::BUILTIN_TYPE_INT, $nullable),
141+
new Type(Type::BUILTIN_TYPE_STRING, $nullable),
142+
];
143+
}
144+
135145
$enumType = null;
136146
if (null !== $enumClass = self::getMappingValue($metadata->getFieldMapping($property), 'enumType') ?? null) {
137147
$enumType = new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, $enumClass);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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\Bridge\Doctrine\Tests\Fixtures;
13+
14+
use Doctrine\ORM\EntityRepository;
15+
16+
class MockableRepository extends EntityRepository
17+
{
18+
public function findByCustom()
19+
{
20+
}
21+
}

src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Doctrine\Common\EventManager;
1616
use Doctrine\DBAL\DriverManager;
1717
use Doctrine\DBAL\Schema\DefaultSchemaManagerFactory;
18+
use Doctrine\DBAL\Types\BigIntType;
1819
use Doctrine\DBAL\Types\Type as DBALType;
1920
use Doctrine\ORM\EntityManager;
2021
use Doctrine\ORM\Mapping\Driver\AttributeDriver;
@@ -143,10 +144,17 @@ public function testExtractEnum()
143144

144145
public static function typesProvider(): array
145146
{
147+
// DBAL 4 has a special fallback strategy for BINGINT (int -> string)
148+
if (!method_exists(BigIntType::class, 'getName')) {
149+
$expectedBingIntType = [new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_STRING)];
150+
} else {
151+
$expectedBingIntType = [new Type(Type::BUILTIN_TYPE_STRING)];
152+
}
153+
146154
return [
147155
['id', [new Type(Type::BUILTIN_TYPE_INT)]],
148156
['guid', [new Type(Type::BUILTIN_TYPE_STRING)]],
149-
['bigint', [new Type(Type::BUILTIN_TYPE_STRING)]],
157+
['bigint', $expectedBingIntType],
150158
['time', [new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateTime')]],
151159
['timeImmutable', [new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateTimeImmutable')]],
152160
['dateInterval', [new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateInterval')]],

src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,14 +236,11 @@ private function getManager($em, $name = null)
236236

237237
private function getObjectManager($repository)
238238
{
239-
$em = $this->getMockBuilder(ObjectManager::class)
240-
->onlyMethods(['getClassMetadata', 'getRepository'])
241-
->getMockForAbstractClass();
242-
$em->expects($this->any())
243-
->method('getRepository')
239+
$objectManager = $this->createMock(ObjectManager::class);
240+
$objectManager->method('getRepository')
244241
->willReturn($repository);
245242

246-
return $em;
243+
return $objectManager;
247244
}
248245

249246
private function createSchema($em)

src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
use Symfony\Bridge\Doctrine\Tests\Fixtures\DoubleNameEntity;
2929
use Symfony\Bridge\Doctrine\Tests\Fixtures\DoubleNullableNameEntity;
3030
use Symfony\Bridge\Doctrine\Tests\Fixtures\Employee;
31+
use Symfony\Bridge\Doctrine\Tests\Fixtures\MockableRepository;
3132
use Symfony\Bridge\Doctrine\Tests\Fixtures\Person;
3233
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity;
3334
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdNoToStringEntity;
@@ -85,14 +86,10 @@ protected function createRegistryMock($em = null)
8586

8687
protected function createRepositoryMock()
8788
{
88-
$repository = $this->getMockBuilder(EntityRepository::class)
89+
return $this->getMockBuilder(MockableRepository::class)
8990
->disableOriginalConstructor()
90-
->onlyMethods(['find', 'findAll', 'findOneBy', 'findBy', 'getClassName'])
91-
->addMethods(['findByCustom'])
92-
->getMock()
93-
;
94-
95-
return $repository;
91+
->onlyMethods(['find', 'findAll', 'findOneBy', 'findBy', 'getClassName', 'findByCustom'])
92+
->getMock();
9693
}
9794

9895
protected function createEntityManagerMock($repositoryMock)

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,12 @@ private static function getPhpUnitErrorHandler(): callable
376376

377377
if ('PHPUnit\Util\ErrorHandler::handleError' === $eh) {
378378
return $eh;
379+
} elseif (ErrorHandler::class === $eh) {
380+
return function (int $errorNumber, string $errorString, string $errorFile, int $errorLine) {
381+
ErrorHandler::instance()($errorNumber, $errorString, $errorFile, $errorLine);
382+
383+
return true;
384+
};
379385
}
380386

381387
foreach (debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT | \DEBUG_BACKTRACE_IGNORE_ARGS) as $frame) {

src/Symfony/Bridge/Twig/Test/Traits/RuntimeLoaderProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ trait RuntimeLoaderProvider
2020
protected function registerTwigRuntimeLoader(Environment $environment, FormRenderer $renderer)
2121
{
2222
$loader = $this->createMock(RuntimeLoaderInterface::class);
23-
$loader->expects($this->any())->method('load')->will($this->returnValueMap([
23+
$loader->expects($this->any())->method('load')->willReturnMap([
2424
['Symfony\Component\Form\FormRenderer', $renderer],
25-
]));
25+
]);
2626
$environment->addRuntimeLoader($loader);
2727
}
2828
}

src/Symfony/Bridge/Twig/Tests/Extension/HttpKernelExtensionTest.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class HttpKernelExtensionTest extends TestCase
3030
{
3131
public function testFragmentWithError()
3232
{
33-
$renderer = $this->getFragmentHandler($this->throwException(new \Exception('foo')));
33+
$renderer = $this->getFragmentHandler(new \Exception('foo'));
3434

3535
$this->expectException(\Twig\Error\RuntimeError::class);
3636

@@ -39,7 +39,7 @@ public function testFragmentWithError()
3939

4040
public function testRenderFragment()
4141
{
42-
$renderer = $this->getFragmentHandler($this->returnValue(new Response('html')));
42+
$renderer = $this->getFragmentHandler(new Response('html'));
4343

4444
$response = $this->renderTemplate($renderer);
4545

@@ -84,11 +84,17 @@ public function testGenerateFragmentUri()
8484
$this->assertSame('/_fragment?_hash=PP8%2FeEbn1pr27I9wmag%2FM6jYGVwUZ0l2h0vhh2OJ6CI%3D&amp;_path=template%3Dfoo.html.twig%26_format%3Dhtml%26_locale%3Den%26_controller%3DSymfonyBundleFrameworkBundleControllerTemplateController%253A%253AtemplateAction', $twig->render('index'));
8585
}
8686

87-
protected function getFragmentHandler($return)
87+
protected function getFragmentHandler($returnOrException): FragmentHandler
8888
{
8989
$strategy = $this->createMock(FragmentRendererInterface::class);
9090
$strategy->expects($this->once())->method('getName')->willReturn('inline');
91-
$strategy->expects($this->once())->method('render')->will($return);
91+
92+
$mocker = $strategy->expects($this->once())->method('render');
93+
if ($returnOrException instanceof \Exception) {
94+
$mocker->willThrowException($returnOrException);
95+
} else {
96+
$mocker->willReturn($returnOrException);
97+
}
9298

9399
$context = $this->createMock(RequestStack::class);
94100

src/Symfony/Component/Config/Tests/Definition/BaseNodeTest.php

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,36 @@ public function testGetPathForChildNode(string $expected, array $params)
3636
}
3737
}
3838

39-
$node = $this->getMockForAbstractClass(BaseNode::class, $constructorArgs);
39+
$node = new class(...$constructorArgs) extends BaseNode {
40+
protected function validateType($value): void
41+
{
42+
}
43+
44+
protected function normalizeValue($value)
45+
{
46+
return null;
47+
}
48+
49+
protected function mergeValues($leftSide, $rightSide)
50+
{
51+
return null;
52+
}
53+
54+
protected function finalizeValue($value)
55+
{
56+
return null;
57+
}
58+
59+
public function hasDefaultValue(): bool
60+
{
61+
return true;
62+
}
63+
64+
public function getDefaultValue()
65+
{
66+
return null;
67+
}
68+
};
4069

4170
$this->assertSame($expected, $node->getPath());
4271
}

0 commit comments

Comments
 (0)