Skip to content

Commit 30a1986

Browse files
Merge branch '3.4' into 4.2
* 3.4: [FrameworkBundle] [SecurityBundle] Rename internal WebTestCase to avoid confusion revert private properties handling [HttpFoundation] Fix URLs [VarDumper] finish PHP 7.4 support and add tests [VarDumper] Use \ReflectionReference for determining if a key is a reference (php >= 7.4) Ignore missing translation dependency in FrameworkBundle [Debug][ExceptionHandler] Add tests for custom handlers
2 parents 79a9bf1 + 789c330 commit 30a1986

39 files changed

+178
-59
lines changed

src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<argument type="service" id="validator.validator_factory" />
2424
</call>
2525
<call method="setTranslator">
26-
<argument type="service" id="translator" />
26+
<argument type="service" id="translator" on-invalid="ignore" />
2727
</call>
2828
<call method="setTranslationDomain">
2929
<argument>%validator.translation_domain%</argument>

src/Symfony/Bundle/FrameworkBundle/Tests/ClientTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
namespace Symfony\Bundle\FrameworkBundle\Tests;
1313

1414
use Symfony\Bundle\FrameworkBundle\Client;
15-
use Symfony\Bundle\FrameworkBundle\Tests\Functional\WebTestCase;
15+
use Symfony\Bundle\FrameworkBundle\Tests\Functional\AbstractWebTestCase;
1616
use Symfony\Component\HttpFoundation\Response;
1717

18-
class ClientTest extends WebTestCase
18+
class ClientTest extends AbstractWebTestCase
1919
{
2020
public function testRebootKernelBetweenRequests()
2121
{

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -828,9 +828,9 @@ public function testValidation()
828828
$this->assertEquals([new Reference('validator.validator_factory')], $calls[0][1]);
829829
$this->assertSame('setTranslator', $calls[1][0]);
830830
if (interface_exists(TranslatorInterface::class) && class_exists(LegacyTranslatorProxy::class)) {
831-
$this->assertEquals([new Definition(LegacyTranslatorProxy::class, [new Reference('translator')])], $calls[1][1]);
831+
$this->assertEquals([new Definition(LegacyTranslatorProxy::class, [new Reference('translator', ContainerInterface::IGNORE_ON_INVALID_REFERENCE)])], $calls[1][1]);
832832
} else {
833-
$this->assertEquals([new Reference('translator')], $calls[1][1]);
833+
$this->assertEquals([new Reference('translator', ContainerInterface::IGNORE_ON_INVALID_REFERENCE)], $calls[1][1]);
834834
}
835835
$this->assertSame('setTranslationDomain', $calls[2][0]);
836836
$this->assertSame(['%validator.translation_domain%'], $calls[2][1]);

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/WebTestCase.php renamed to src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AbstractWebTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase as BaseWebTestCase;
1515
use Symfony\Component\Filesystem\Filesystem;
1616

17-
class WebTestCase extends BaseWebTestCase
17+
abstract class AbstractWebTestCase extends BaseWebTestCase
1818
{
1919
public static function assertRedirect($response, $location)
2020
{

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AnnotatedControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
1313

14-
class AnnotatedControllerTest extends WebTestCase
14+
class AnnotatedControllerTest extends AbstractWebTestCase
1515
{
1616
/**
1717
* @dataProvider getRoutes

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AutowiringTypesTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
use Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher;
2020
use Symfony\Component\Templating\EngineInterface as ComponentEngineInterface;
2121

22-
class AutowiringTypesTest extends WebTestCase
22+
class AutowiringTypesTest extends AbstractWebTestCase
2323
{
2424
public function testAnnotationReaderAutowiring()
2525
{

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolClearCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
/**
1919
* @group functional
2020
*/
21-
class CachePoolClearCommandTest extends WebTestCase
21+
class CachePoolClearCommandTest extends AbstractWebTestCase
2222
{
2323
protected function setUp()
2424
{

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use Symfony\Component\Cache\Adapter\TagAwareAdapter;
1717
use Symfony\Component\Cache\Exception\InvalidArgumentException;
1818

19-
class CachePoolsTest extends WebTestCase
19+
class CachePoolsTest extends AbstractWebTestCase
2020
{
2121
public function testCachePools()
2222
{

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDebugCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
/**
2020
* @group functional
2121
*/
22-
class ConfigDebugCommandTest extends WebTestCase
22+
class ConfigDebugCommandTest extends AbstractWebTestCase
2323
{
2424
private $application;
2525

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ConfigDumpReferenceCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
/**
2020
* @group functional
2121
*/
22-
class ConfigDumpReferenceCommandTest extends WebTestCase
22+
class ConfigDumpReferenceCommandTest extends AbstractWebTestCase
2323
{
2424
private $application;
2525

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ContainerDebugCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
/**
1919
* @group functional
2020
*/
21-
class ContainerDebugCommandTest extends WebTestCase
21+
class ContainerDebugCommandTest extends AbstractWebTestCase
2222
{
2323
public function testDumpContainerIfNotExists()
2424
{

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ContainerDumpTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
/**
1515
* Checks that the container compiles correctly when all the bundle features are enabled.
1616
*/
17-
class ContainerDumpTest extends WebTestCase
17+
class ContainerDumpTest extends AbstractWebTestCase
1818
{
1919
public function testContainerCompilationInDebug()
2020
{

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/DebugAutowiringCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
/**
1818
* @group functional
1919
*/
20-
class DebugAutowiringCommandTest extends WebTestCase
20+
class DebugAutowiringCommandTest extends AbstractWebTestCase
2121
{
2222
public function testBasicFunctionality()
2323
{

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/FragmentTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
1313

14-
class FragmentTest extends WebTestCase
14+
class FragmentTest extends AbstractWebTestCase
1515
{
1616
/**
1717
* @dataProvider getConfigs

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/ProfilerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
1313

14-
class ProfilerTest extends WebTestCase
14+
class ProfilerTest extends AbstractWebTestCase
1515
{
1616
/**
1717
* @dataProvider getConfigs

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/PropertyInfoTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
use Symfony\Component\PropertyInfo\Type;
1515

16-
class PropertyInfoTest extends WebTestCase
16+
class PropertyInfoTest extends AbstractWebTestCase
1717
{
1818
public function testPhpDocPriority()
1919
{

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SerializerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
/**
1515
* @author Kévin Dunglas <dunglas@gmail.com>
1616
*/
17-
class SerializerTest extends WebTestCase
17+
class SerializerTest extends AbstractWebTestCase
1818
{
1919
public function testDeserializeArrayOfObject()
2020
{

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SessionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
1313

14-
class SessionTest extends WebTestCase
14+
class SessionTest extends AbstractWebTestCase
1515
{
1616
/**
1717
* Tests session attributes persist.

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/SubRequestsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
1313

14-
class SubRequestsTest extends WebTestCase
14+
class SubRequestsTest extends AbstractWebTestCase
1515
{
1616
public function testStateAfterSubRequest()
1717
{

src/Symfony/Bundle/SecurityBundle/Tests/Functional/WebTestCase.php renamed to src/Symfony/Bundle/SecurityBundle/Tests/Functional/AbstractWebTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase as BaseWebTestCase;
1515
use Symfony\Component\Filesystem\Filesystem;
1616

17-
class WebTestCase extends BaseWebTestCase
17+
class AbstractWebTestCase extends BaseWebTestCase
1818
{
1919
public static function assertRedirect($response, $location)
2020
{

src/Symfony/Bundle/SecurityBundle/Tests/Functional/AuthenticationCommencingTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Bundle\SecurityBundle\Tests\Functional;
1313

14-
class AuthenticationCommencingTest extends WebTestCase
14+
class AuthenticationCommencingTest extends AbstractWebTestCase
1515
{
1616
public function testAuthenticationIsCommencingIfAccessDeniedExceptionIsWrapped()
1717
{

src/Symfony/Bundle/SecurityBundle/Tests/Functional/AutowiringTypesTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Symfony\Component\Security\Core\Authorization\AccessDecisionManager;
1515
use Symfony\Component\Security\Core\Authorization\TraceableAccessDecisionManager;
1616

17-
class AutowiringTypesTest extends WebTestCase
17+
class AutowiringTypesTest extends AbstractWebTestCase
1818
{
1919
public function testAccessDecisionManagerAutowiring()
2020
{

src/Symfony/Bundle/SecurityBundle/Tests/Functional/CsrfFormLoginTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Bundle\SecurityBundle\Tests\Functional;
1313

14-
class CsrfFormLoginTest extends WebTestCase
14+
class CsrfFormLoginTest extends AbstractWebTestCase
1515
{
1616
/**
1717
* @dataProvider getConfigs

src/Symfony/Bundle/SecurityBundle/Tests/Functional/FirewallEntryPointTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
use Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\FirewallEntryPointBundle\Security\EntryPointStub;
1515

16-
class FirewallEntryPointTest extends WebTestCase
16+
class FirewallEntryPointTest extends AbstractWebTestCase
1717
{
1818
public function testItUsesTheConfiguredEntryPointWhenUsingUnknownCredentials()
1919
{

src/Symfony/Bundle/SecurityBundle/Tests/Functional/FormLoginTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Bundle\SecurityBundle\Tests\Functional;
1313

14-
class FormLoginTest extends WebTestCase
14+
class FormLoginTest extends AbstractWebTestCase
1515
{
1616
/**
1717
* @dataProvider getConfigs

src/Symfony/Bundle/SecurityBundle/Tests/Functional/JsonLoginTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
/**
1717
* @author Kévin Dunglas <dunglas@gmail.com>
1818
*/
19-
class JsonLoginTest extends WebTestCase
19+
class JsonLoginTest extends AbstractWebTestCase
2020
{
2121
public function testDefaultJsonLoginSuccess()
2222
{

src/Symfony/Bundle/SecurityBundle/Tests/Functional/LocalizedRoutesAsPathTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Bundle\SecurityBundle\Tests\Functional;
1313

14-
class LocalizedRoutesAsPathTest extends WebTestCase
14+
class LocalizedRoutesAsPathTest extends AbstractWebTestCase
1515
{
1616
/**
1717
* @dataProvider getLocales

src/Symfony/Bundle/SecurityBundle/Tests/Functional/LogoutTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Bundle\SecurityBundle\Tests\Functional;
1313

14-
class LogoutTest extends WebTestCase
14+
class LogoutTest extends AbstractWebTestCase
1515
{
1616
public function testSessionLessRememberMeLogout()
1717
{

src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityRoutingIntegrationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Bundle\SecurityBundle\Tests\Functional;
1313

14-
class SecurityRoutingIntegrationTest extends WebTestCase
14+
class SecurityRoutingIntegrationTest extends AbstractWebTestCase
1515
{
1616
/**
1717
* @dataProvider getConfigs

src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
1515
use Symfony\Component\Security\Core\User\User;
1616

17-
class SecurityTest extends WebTestCase
17+
class SecurityTest extends AbstractWebTestCase
1818
{
1919
public function testServiceIsFunctional()
2020
{

src/Symfony/Bundle/SecurityBundle/Tests/Functional/SwitchUserTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Symfony\Component\HttpFoundation\JsonResponse;
1515
use Symfony\Component\Security\Http\Firewall\SwitchUserListener;
1616

17-
class SwitchUserTest extends WebTestCase
17+
class SwitchUserTest extends AbstractWebTestCase
1818
{
1919
/**
2020
* @dataProvider getTestParameters

src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
*
2626
* @author Sarah Khalil <mkhalil.sarah@gmail.com>
2727
*/
28-
class UserPasswordEncoderCommandTest extends WebTestCase
28+
class UserPasswordEncoderCommandTest extends AbstractWebTestCase
2929
{
3030
/** @var CommandTester */
3131
private $passwordEncoderCommandTester;

src/Symfony/Component/Debug/Tests/ExceptionHandlerTest.php

Lines changed: 48 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function testHeaders()
7676

7777
ob_start();
7878
$handler->sendPhpResponse(new MethodNotAllowedHttpException(['POST']));
79-
$response = ob_get_clean();
79+
ob_get_clean();
8080

8181
$expectedHeaders = [
8282
['HTTP/1.0 405', true, null],
@@ -99,35 +99,65 @@ public function testNestedExceptions()
9999

100100
public function testHandle()
101101
{
102-
$exception = new \Exception('foo');
102+
$handler = new ExceptionHandler(true);
103+
ob_start();
103104

104-
$handler = $this->getMockBuilder('Symfony\Component\Debug\ExceptionHandler')->setMethods(['sendPhpResponse'])->getMock();
105-
$handler
106-
->expects($this->exactly(2))
107-
->method('sendPhpResponse');
105+
$handler->handle(new \Exception('foo'));
108106

109-
$handler->handle($exception);
107+
$this->assertThatTheExceptionWasOutput(ob_get_clean(), \Exception::class, 'Exception', 'foo');
108+
}
110109

111-
$handler->setHandler(function ($e) use ($exception) {
112-
$this->assertSame($exception, $e);
110+
public function testHandleWithACustomHandlerThatOutputsSomething()
111+
{
112+
$handler = new ExceptionHandler(true);
113+
ob_start();
114+
$handler->setHandler(function () {
115+
echo 'ccc';
113116
});
114117

115-
$handler->handle($exception);
118+
$handler->handle(new \Exception());
119+
ob_end_flush(); // Necessary because of this PHP bug : https://bugs.php.net/bug.php?id=76563
120+
$this->assertSame('ccc', ob_get_clean());
116121
}
117122

118-
public function testHandleOutOfMemoryException()
123+
public function testHandleWithACustomHandlerThatOutputsNothing()
124+
{
125+
$handler = new ExceptionHandler(true);
126+
$handler->setHandler(function () {});
127+
128+
$handler->handle(new \Exception('ccc'));
129+
130+
$this->assertThatTheExceptionWasOutput(ob_get_clean(), \Exception::class, 'Exception', 'ccc');
131+
}
132+
133+
public function testHandleWithACustomHandlerThatFails()
119134
{
120-
$exception = new OutOfMemoryException('foo', 0, E_ERROR, __FILE__, __LINE__);
135+
$handler = new ExceptionHandler(true);
136+
$handler->setHandler(function () {
137+
throw new \RuntimeException();
138+
});
121139

122-
$handler = $this->getMockBuilder('Symfony\Component\Debug\ExceptionHandler')->setMethods(['sendPhpResponse'])->getMock();
123-
$handler
124-
->expects($this->once())
125-
->method('sendPhpResponse');
140+
$handler->handle(new \Exception('ccc'));
126141

127-
$handler->setHandler(function ($e) {
142+
$this->assertThatTheExceptionWasOutput(ob_get_clean(), \Exception::class, 'Exception', 'ccc');
143+
}
144+
145+
public function testHandleOutOfMemoryException()
146+
{
147+
$handler = new ExceptionHandler(true);
148+
ob_start();
149+
$handler->setHandler(function () {
128150
$this->fail('OutOfMemoryException should bypass the handler');
129151
});
130152

131-
$handler->handle($exception);
153+
$handler->handle(new OutOfMemoryException('foo', 0, E_ERROR, __FILE__, __LINE__));
154+
155+
$this->assertThatTheExceptionWasOutput(ob_get_clean(), OutOfMemoryException::class, 'OutOfMemoryException', 'foo');
156+
}
157+
158+
private function assertThatTheExceptionWasOutput($content, $expectedClass, $expectedTitle, $expectedMessage)
159+
{
160+
$this->assertContains(sprintf('<span class="exception_title"><abbr title="%s">%s</abbr></span>', $expectedClass, $expectedTitle), $content);
161+
$this->assertContains(sprintf('<p class="break-long-words trace-message">%s</p>', $expectedMessage), $content);
132162
}
133163
}

src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MongoDbSessionHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* @author Markus Bachmann <markus.bachmann@bachi.biz>
1818
*
1919
* @see https://packagist.org/packages/mongodb/mongodb
20-
* @see http://php.net/manual/en/set.mongodb.php
20+
* @see https://php.net/mongodb
2121
*/
2222
class MongoDbSessionHandler extends AbstractSessionHandler
2323
{

0 commit comments

Comments
 (0)