Skip to content

Commit c58c599

Browse files
committed
Merge branch '7.0' into 7.1
* 7.0: [Serializer] Improve exception message in UnwrappingDenormalizer [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 Return false in isTtySupported() when open_basedir restrictions prevent access to /dev/tty. Remove calls to `TestCase::iniSet()` and calls to deprecated methods of `MockBuilder` [PhpUnitBridge] Fix `DeprecationErrorHandler` with PhpUnit 10
2 parents bb91614 + 142c4be commit c58c599

File tree

111 files changed

+670
-173
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

+670
-173
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;
@@ -236,6 +237,15 @@ public function getTypes(string $class, string $property, array $context = []):
236237
}
237238

238239
$nullable = $metadata instanceof ClassMetadata && $metadata->isNullable($property);
240+
241+
// DBAL 4 has a special fallback strategy for BINGINT (int -> string)
242+
if (Types::BIGINT === $typeOfField && !method_exists(BigIntType::class, 'getName')) {
243+
return [
244+
new Type(Type::BUILTIN_TYPE_INT, $nullable),
245+
new Type(Type::BUILTIN_TYPE_STRING, $nullable),
246+
];
247+
}
248+
239249
$enumType = null;
240250
if (null !== $enumClass = self::getMappingValue($metadata->getFieldMapping($property), 'enumType') ?? null) {
241251
$enumType = new LegacyType(LegacyType::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 <[email protected]>
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;
@@ -153,10 +154,17 @@ public function testExtractEnumLegacy()
153154
*/
154155
public static function legacyTypesProvider(): array
155156
{
157+
// DBAL 4 has a special fallback strategy for BINGINT (int -> string)
158+
if (!method_exists(BigIntType::class, 'getName')) {
159+
$expectedBingIntType = [new LegacyType(LegacyType::BUILTIN_TYPE_INT), new Type(LegacyType::BUILTIN_TYPE_STRING)];
160+
} else {
161+
$expectedBingIntType = [new LegacyType(LegacyType::BUILTIN_TYPE_STRING)];
162+
}
163+
156164
return [
157165
['id', [new LegacyType(LegacyType::BUILTIN_TYPE_INT)]],
158166
['guid', [new LegacyType(LegacyType::BUILTIN_TYPE_STRING)]],
159-
['bigint', [new LegacyType(LegacyType::BUILTIN_TYPE_STRING)]],
167+
['bigint', $expectedBingIntType],
160168
['time', [new LegacyType(LegacyType::BUILTIN_TYPE_OBJECT, false, 'DateTime')]],
161169
['timeImmutable', [new LegacyType(LegacyType::BUILTIN_TYPE_OBJECT, false, 'DateTimeImmutable')]],
162170
['dateInterval', [new LegacyType(LegacyType::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
@@ -31,6 +31,7 @@
3131
use Symfony\Bridge\Doctrine\Tests\Fixtures\Dto;
3232
use Symfony\Bridge\Doctrine\Tests\Fixtures\Employee;
3333
use Symfony\Bridge\Doctrine\Tests\Fixtures\HireAnEmployee;
34+
use Symfony\Bridge\Doctrine\Tests\Fixtures\MockableRepository;
3435
use Symfony\Bridge\Doctrine\Tests\Fixtures\Person;
3536
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity;
3637
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdNoToStringEntity;
@@ -91,14 +92,10 @@ protected function createRegistryMock($em = null)
9192

9293
protected function createRepositoryMock()
9394
{
94-
$repository = $this->getMockBuilder(EntityRepository::class)
95+
return $this->getMockBuilder(MockableRepository::class)
9596
->disableOriginalConstructor()
96-
->onlyMethods(['find', 'findAll', 'findOneBy', 'findBy', 'getClassName'])
97-
->addMethods(['findByCustom'])
98-
->getMock()
99-
;
100-
101-
return $repository;
97+
->onlyMethods(['find', 'findAll', 'findOneBy', 'findBy', 'getClassName', 'findByCustom'])
98+
->getMock();
10299
}
103100

104101
protected function createEntityManagerMock($repositoryMock)

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

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

368368
if ('PHPUnit\Util\ErrorHandler::handleError' === $eh) {
369369
return $eh;
370+
} elseif (ErrorHandler::class === $eh) {
371+
return function (int $errorNumber, string $errorString, string $errorFile, int $errorLine) {
372+
ErrorHandler::instance()($errorNumber, $errorString, $errorFile, $errorLine);
373+
374+
return true;
375+
};
370376
}
371377

372378
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

@@ -83,11 +83,17 @@ public function testGenerateFragmentUri()
8383
$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'));
8484
}
8585

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

9298
$context = new RequestStack();
9399

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)