Skip to content

Commit

Permalink
Merge branch '6.4' into 7.1
Browse files Browse the repository at this point in the history
* 6.4:
  [Serializer] Fix for method named `get()`
  [Notifier][TurboSMS] Process partial accepted response from transport
  [HttpClient] Fix setting CURLMOPT_MAXCONNECTS
  throw a meaningful exception when parsing dotenv files with BOM
  [FrameworkBundle] Fix schema & finish incomplete tests for lock & semaphore config
  [Cache] Fix RedisSentinel params types
  [FrameworkBundle] Fix service reset between tests
  [Uid][Serializer][Validator] Mention RFC 9562
  make sure temp files can be cleaned up on Windows
  • Loading branch information
xabbuh committed Sep 17, 2024
2 parents 0c93dc1 + 40aa18d commit 0e6c77a
Show file tree
Hide file tree
Showing 13 changed files with 165 additions and 5 deletions.
5 changes: 5 additions & 0 deletions Test/KernelTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ protected static function ensureKernelShutdown()
static::$kernel->shutdown();
static::$booted = false;

if ($container->has('services_resetter')) {
// Instantiate the service because Container::reset() only resets services that have been used
$container->get('services_resetter');
}

if ($container instanceof ResetInterface) {
$container->reset();
}
Expand Down
9 changes: 9 additions & 0 deletions Tests/DependencyInjection/Fixtures/php/lock.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

$container->loadFromExtension('framework', [
'annotations' => false,
'http_method_override' => false,
'handle_all_throwables' => true,
'php_errors' => ['log' => true],
'lock' => null,
]);
16 changes: 16 additions & 0 deletions Tests/DependencyInjection/Fixtures/php/lock_named.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

$container->setParameter('env(REDIS_DSN)', 'redis://paas.com');

$container->loadFromExtension('framework', [
'annotations' => false,
'http_method_override' => false,
'handle_all_throwables' => true,
'php_errors' => ['log' => true],
'lock' => [
'foo' => 'semaphore',
'bar' => 'flock',
'baz' => ['semaphore', 'flock'],
'qux' => '%env(REDIS_DSN)%',
],
]);
9 changes: 9 additions & 0 deletions Tests/DependencyInjection/Fixtures/php/semaphore.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

$container->loadFromExtension('framework', [
'annotations' => false,
'http_method_override' => false,
'handle_all_throwables' => true,
'php_errors' => ['log' => true],
'semaphore' => 'redis://localhost',
]);
14 changes: 14 additions & 0 deletions Tests/DependencyInjection/Fixtures/php/semaphore_named.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

$container->setParameter('env(REDIS_DSN)', 'redis://paas.com');

$container->loadFromExtension('framework', [
'annotations' => false,
'http_method_override' => false,
'handle_all_throwables' => true,
'php_errors' => ['log' => true],
'semaphore' => [
'foo' => 'redis://paas.com',
'qux' => '%env(REDIS_DSN)%',
],
]);
4 changes: 3 additions & 1 deletion Tests/DependencyInjection/Fixtures/xml/lock.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<framework:config http-method-override="false" handle-all-throwables="true">
<framework:annotations enabled="false" />
<framework:php-errors log="true" />
<framework:lock/>
<framework:lock>
<framework:resource>semaphore</framework:resource>
</framework:lock>
</framework:config>
</container>
3 changes: 1 addition & 2 deletions Tests/DependencyInjection/Fixtures/xml/lock_named.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">


<parameters>
<parameter key="env(REDIS_URL)">redis://paas.com</parameter>
</parameters>
Expand All @@ -18,7 +17,7 @@
<framework:resource name="bar">flock</framework:resource>
<framework:resource name="baz">semaphore</framework:resource>
<framework:resource name="baz">flock</framework:resource>
<framework:resource name="qux">%env(REDIS_URL)%</framework:resource>
<framework:resource name="qux">%env(REDIS_DSN)%</framework:resource>
</framework:lock>
</framework:config>
</container>
4 changes: 3 additions & 1 deletion Tests/DependencyInjection/Fixtures/xml/semaphore.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<framework:config http-method-override="false" handle-all-throwables="true">
<framework:annotations enabled="false" />
<framework:php-errors log="true" />
<framework:semaphore/>
<framework:semaphore>
<framework:resource>redis://localhost</framework:resource>
</framework:semaphore>
</framework:config>
</container>
16 changes: 16 additions & 0 deletions Tests/DependencyInjection/Fixtures/xml/semaphore_named.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:framework="http://symfony.com/schema/dic/symfony"
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">

<framework:config http-method-override="false" handle-all-throwables="true">
<framework:annotations enabled="false" />
<framework:php-errors log="true" />
<framework:semaphore>
<framework:resource name="foo">redis://paas.com</framework:resource>
<framework:resource name="qux">%env(REDIS_DSN)%</framework:resource>
</framework:semaphore>
</framework:config>
</container>
56 changes: 56 additions & 0 deletions Tests/DependencyInjection/FrameworkExtensionTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2386,6 +2386,62 @@ public function testAssetMapperWithoutAssets()
$this->assertFalse($container->has('assets._default_package'));
}

public function testDefaultLock()
{
$container = $this->createContainerFromFile('lock');

self::assertTrue($container->hasDefinition('lock.default.factory'));
$storeDef = $container->getDefinition($container->getDefinition('lock.default.factory')->getArgument(0));
self::assertEquals(new Reference('semaphore'), $storeDef->getArgument(0));
}

public function testNamedLocks()
{
$container = $this->createContainerFromFile('lock_named');

self::assertTrue($container->hasDefinition('lock.foo.factory'));
$storeDef = $container->getDefinition($container->getDefinition('lock.foo.factory')->getArgument(0));
self::assertEquals(new Reference('semaphore'), $storeDef->getArgument(0));

self::assertTrue($container->hasDefinition('lock.bar.factory'));
$storeDef = $container->getDefinition($container->getDefinition('lock.bar.factory')->getArgument(0));
self::assertEquals(new Reference('flock'), $storeDef->getArgument(0));

self::assertTrue($container->hasDefinition('lock.baz.factory'));
$storeDef = $container->getDefinition($container->getDefinition('lock.baz.factory')->getArgument(0));
self::assertIsArray($storeDefArg = $storeDef->getArgument(0));
$storeDef1 = $container->getDefinition($storeDefArg[0]);
$storeDef2 = $container->getDefinition($storeDefArg[1]);
self::assertEquals(new Reference('semaphore'), $storeDef1->getArgument(0));
self::assertEquals(new Reference('flock'), $storeDef2->getArgument(0));

self::assertTrue($container->hasDefinition('lock.qux.factory'));
$storeDef = $container->getDefinition($container->getDefinition('lock.qux.factory')->getArgument(0));
self::assertStringContainsString('REDIS_DSN', $storeDef->getArgument(0));
}

public function testDefaultSemaphore()
{
$container = $this->createContainerFromFile('semaphore');

self::assertTrue($container->hasDefinition('semaphore.default.factory'));
$storeDef = $container->getDefinition($container->getDefinition('semaphore.default.factory')->getArgument(0));
self::assertSame('redis://localhost', $storeDef->getArgument(0));
}

public function testNamedSemaphores()
{
$container = $this->createContainerFromFile('semaphore_named');

self::assertTrue($container->hasDefinition('semaphore.foo.factory'));
$storeDef = $container->getDefinition($container->getDefinition('semaphore.foo.factory')->getArgument(0));
self::assertSame('redis://paas.com', $storeDef->getArgument(0));

self::assertTrue($container->hasDefinition('semaphore.qux.factory'));
$storeDef = $container->getDefinition($container->getDefinition('semaphore.qux.factory')->getArgument(0));
self::assertStringContainsString('REDIS_DSN', $storeDef->getArgument(0));
}

protected function createContainer(array $data = [])
{
return new ContainerBuilder(new EnvPlaceholderParameterBag(array_merge([
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestServiceContainer;

class ResettableService
{
private $count = 0;

public function myCustomName(): void
{
++$this->count;
}

public function getCount(): int
{
return $this->count;
}
}
5 changes: 5 additions & 0 deletions Tests/Functional/app/TestServiceContainer/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,8 @@ services:
decorates: decorated
properties:
inner: '@.inner'

Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestServiceContainer\ResettableService:
public: true
tags:
- kernel.reset: { method: 'myCustomName' }
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"ext-xml": "*",
"symfony/cache": "^6.4|^7.0",
"symfony/config": "^6.4|^7.0",
"symfony/dependency-injection": "^7.1",
"symfony/dependency-injection": "^7.1.5",
"symfony/deprecation-contracts": "^2.5|^3",
"symfony/error-handler": "^6.4|^7.0",
"symfony/event-dispatcher": "^6.4|^7.0",
Expand Down

0 comments on commit 0e6c77a

Please sign in to comment.