summaryrefslogtreecommitdiff
path: root/vendor/symfony/http-kernel/Tests
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/symfony/http-kernel/Tests')
-rw-r--r--vendor/symfony/http-kernel/Tests/Config/FileLocatorTest.php2
-rw-r--r--vendor/symfony/http-kernel/Tests/Controller/ArgumentResolver/NotTaggedControllerValueResolverTest.php117
-rw-r--r--vendor/symfony/http-kernel/Tests/DataCollector/DumpDataCollectorTest.php10
-rw-r--r--vendor/symfony/http-kernel/Tests/DataCollector/RequestDataCollectorTest.php62
-rw-r--r--vendor/symfony/http-kernel/Tests/Debug/FileLinkFormatterTest.php12
-rw-r--r--vendor/symfony/http-kernel/Tests/Debug/TraceableEventDispatcherTest.php7
-rw-r--r--vendor/symfony/http-kernel/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php13
-rw-r--r--vendor/symfony/http-kernel/Tests/DependencyInjection/RegisterLocaleAwareServicesPassTest.php59
-rw-r--r--vendor/symfony/http-kernel/Tests/Event/ControllerArgumentsEventTest.php17
-rw-r--r--vendor/symfony/http-kernel/Tests/Event/ExceptionEventTest.php (renamed from vendor/symfony/http-kernel/Tests/Event/GetResponseForExceptionEventTest.php)6
-rw-r--r--vendor/symfony/http-kernel/Tests/Event/FilterControllerArgumentsEventTest.php17
-rw-r--r--vendor/symfony/http-kernel/Tests/EventListener/AddRequestFormatsListenerTest.php9
-rw-r--r--vendor/symfony/http-kernel/Tests/EventListener/DebugHandlersListenerTest.php2
-rw-r--r--vendor/symfony/http-kernel/Tests/EventListener/DisallowRobotsIndexingListenerTest.php47
-rw-r--r--vendor/symfony/http-kernel/Tests/EventListener/ExceptionListenerTest.php20
-rw-r--r--vendor/symfony/http-kernel/Tests/EventListener/FragmentListenerTest.php20
-rw-r--r--vendor/symfony/http-kernel/Tests/EventListener/LocaleAwareListenerTest.php119
-rw-r--r--vendor/symfony/http-kernel/Tests/EventListener/LocaleListenerTest.php28
-rw-r--r--vendor/symfony/http-kernel/Tests/EventListener/ProfilerListenerTest.php14
-rw-r--r--vendor/symfony/http-kernel/Tests/EventListener/ResponseListenerTest.php18
-rw-r--r--vendor/symfony/http-kernel/Tests/EventListener/RouterListenerTest.php30
-rw-r--r--vendor/symfony/http-kernel/Tests/EventListener/SaveSessionListenerTest.php6
-rw-r--r--vendor/symfony/http-kernel/Tests/EventListener/SessionListenerTest.php26
-rw-r--r--vendor/symfony/http-kernel/Tests/EventListener/SurrogateListenerTest.php14
-rw-r--r--vendor/symfony/http-kernel/Tests/EventListener/TestSessionListenerTest.php20
-rw-r--r--vendor/symfony/http-kernel/Tests/EventListener/TranslatorListenerTest.php9
-rw-r--r--vendor/symfony/http-kernel/Tests/EventListener/ValidateRequestListenerTest.php6
-rw-r--r--vendor/symfony/http-kernel/Tests/Exception/AccessDeniedHttpExceptionTest.php4
-rw-r--r--vendor/symfony/http-kernel/Tests/Exception/BadRequestHttpExceptionTest.php4
-rw-r--r--vendor/symfony/http-kernel/Tests/Exception/ConflictHttpExceptionTest.php4
-rw-r--r--vendor/symfony/http-kernel/Tests/Exception/GoneHttpExceptionTest.php4
-rw-r--r--vendor/symfony/http-kernel/Tests/Exception/HttpExceptionTest.php12
-rw-r--r--vendor/symfony/http-kernel/Tests/Exception/LengthRequiredHttpExceptionTest.php4
-rw-r--r--vendor/symfony/http-kernel/Tests/Exception/MethodNotAllowedHttpExceptionTest.php5
-rw-r--r--vendor/symfony/http-kernel/Tests/Exception/NotAcceptableHttpExceptionTest.php4
-rw-r--r--vendor/symfony/http-kernel/Tests/Exception/NotFoundHttpExceptionTest.php4
-rw-r--r--vendor/symfony/http-kernel/Tests/Exception/PreconditionFailedHttpExceptionTest.php4
-rw-r--r--vendor/symfony/http-kernel/Tests/Exception/PreconditionRequiredHttpExceptionTest.php4
-rw-r--r--vendor/symfony/http-kernel/Tests/Exception/ServiceUnavailableHttpExceptionTest.php4
-rw-r--r--vendor/symfony/http-kernel/Tests/Exception/TooManyRequestsHttpExceptionTest.php4
-rw-r--r--vendor/symfony/http-kernel/Tests/Exception/UnauthorizedHttpExceptionTest.php5
-rw-r--r--vendor/symfony/http-kernel/Tests/Exception/UnprocessableEntityHttpExceptionTest.php4
-rw-r--r--vendor/symfony/http-kernel/Tests/Exception/UnsupportedMediaTypeHttpExceptionTest.php4
-rw-r--r--vendor/symfony/http-kernel/Tests/Fixtures/TestClient.php4
-rw-r--r--vendor/symfony/http-kernel/Tests/Fragment/HIncludeFragmentRendererTest.php27
-rw-r--r--vendor/symfony/http-kernel/Tests/Fragment/InlineFragmentRendererTest.php16
-rw-r--r--vendor/symfony/http-kernel/Tests/HttpCache/HttpCacheTest.php38
-rw-r--r--vendor/symfony/http-kernel/Tests/HttpCache/HttpCacheTestCase.php4
-rw-r--r--vendor/symfony/http-kernel/Tests/HttpKernelBrowserTest.php (renamed from vendor/symfony/http-kernel/Tests/ClientTest.php)16
-rw-r--r--vendor/symfony/http-kernel/Tests/HttpKernelTest.php21
-rw-r--r--vendor/symfony/http-kernel/Tests/KernelTest.php19
-rw-r--r--vendor/symfony/http-kernel/Tests/Log/LoggerTest.php2
52 files changed, 712 insertions, 219 deletions
diff --git a/vendor/symfony/http-kernel/Tests/Config/FileLocatorTest.php b/vendor/symfony/http-kernel/Tests/Config/FileLocatorTest.php
index 6265f02755..ca1b3191bd 100644
--- a/vendor/symfony/http-kernel/Tests/Config/FileLocatorTest.php
+++ b/vendor/symfony/http-kernel/Tests/Config/FileLocatorTest.php
@@ -30,7 +30,7 @@ class FileLocatorTest extends TestCase
$kernel
->expects($this->never())
->method('locateResource');
- $this->{method_exists($this, $_ = 'expectException') ? $_ : 'setExpectedException'}('LogicException');
+ $this->expectException('LogicException');
$locator->locate('/some/path');
}
diff --git a/vendor/symfony/http-kernel/Tests/Controller/ArgumentResolver/NotTaggedControllerValueResolverTest.php b/vendor/symfony/http-kernel/Tests/Controller/ArgumentResolver/NotTaggedControllerValueResolverTest.php
new file mode 100644
index 0000000000..bd22adde91
--- /dev/null
+++ b/vendor/symfony/http-kernel/Tests/Controller/ArgumentResolver/NotTaggedControllerValueResolverTest.php
@@ -0,0 +1,117 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\HttpKernel\Tests\Controller\ArgumentResolver;
+
+use PHPUnit\Framework\TestCase;
+use Symfony\Component\DependencyInjection\ServiceLocator;
+use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpKernel\Controller\ArgumentResolver\NotTaggedControllerValueResolver;
+use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata;
+
+class NotTaggedControllerValueResolverTest extends TestCase
+{
+ public function testDoSupportWhenControllerDoNotExists()
+ {
+ $resolver = new NotTaggedControllerValueResolver(new ServiceLocator([]));
+ $argument = new ArgumentMetadata('dummy', \stdClass::class, false, false, null);
+ $request = $this->requestWithAttributes(['_controller' => 'my_controller']);
+
+ $this->assertTrue($resolver->supports($request, $argument));
+ }
+
+ public function testDoNotSupportWhenControllerExists()
+ {
+ $resolver = new NotTaggedControllerValueResolver(new ServiceLocator([
+ 'App\\Controller\\Mine::method' => function () {
+ return new ServiceLocator([
+ 'dummy' => function () {
+ return new \stdClass();
+ },
+ ]);
+ },
+ ]));
+ $argument = new ArgumentMetadata('dummy', \stdClass::class, false, false, null);
+ $request = $this->requestWithAttributes(['_controller' => 'App\\Controller\\Mine::method']);
+
+ $this->assertFalse($resolver->supports($request, $argument));
+ }
+
+ public function testDoNotSupportEmptyController()
+ {
+ $resolver = new NotTaggedControllerValueResolver(new ServiceLocator([]));
+ $argument = new ArgumentMetadata('dummy', \stdClass::class, false, false, null);
+ $request = $this->requestWithAttributes(['_controller' => '']);
+ $this->assertFalse($resolver->supports($request, $argument));
+ }
+
+ /**
+ * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
+ * @expectedExceptionMessage Could not resolve argument $dummy of "App\Controller\Mine::method()", maybe you forgot to register the controller as a service or missed tagging it with the "controller.service_arguments"?
+ */
+ public function testController()
+ {
+ $resolver = new NotTaggedControllerValueResolver(new ServiceLocator([]));
+ $argument = new ArgumentMetadata('dummy', \stdClass::class, false, false, null);
+ $request = $this->requestWithAttributes(['_controller' => 'App\\Controller\\Mine::method']);
+ $this->assertTrue($resolver->supports($request, $argument));
+ $resolver->resolve($request, $argument);
+ }
+
+ /**
+ * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
+ * @expectedExceptionMessage Could not resolve argument $dummy of "App\Controller\Mine::method()", maybe you forgot to register the controller as a service or missed tagging it with the "controller.service_arguments"?
+ */
+ public function testControllerWithATrailingBackSlash()
+ {
+ $resolver = new NotTaggedControllerValueResolver(new ServiceLocator([]));
+ $argument = new ArgumentMetadata('dummy', \stdClass::class, false, false, null);
+ $request = $this->requestWithAttributes(['_controller' => '\\App\\Controller\\Mine::method']);
+ $this->assertTrue($resolver->supports($request, $argument));
+ $resolver->resolve($request, $argument);
+ }
+
+ /**
+ * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
+ * @expectedExceptionMessage Could not resolve argument $dummy of "App\Controller\Mine::method()", maybe you forgot to register the controller as a service or missed tagging it with the "controller.service_arguments"?
+ */
+ public function testControllerWithMethodNameStartUppercase()
+ {
+ $resolver = new NotTaggedControllerValueResolver(new ServiceLocator([]));
+ $argument = new ArgumentMetadata('dummy', \stdClass::class, false, false, null);
+ $request = $this->requestWithAttributes(['_controller' => 'App\\Controller\\Mine::Method']);
+ $this->assertTrue($resolver->supports($request, $argument));
+ $resolver->resolve($request, $argument);
+ }
+
+ /**
+ * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
+ * @expectedExceptionMessage Could not resolve argument $dummy of "App\Controller\Mine::method()", maybe you forgot to register the controller as a service or missed tagging it with the "controller.service_arguments"?
+ */
+ public function testControllerNameIsAnArray()
+ {
+ $resolver = new NotTaggedControllerValueResolver(new ServiceLocator([]));
+ $argument = new ArgumentMetadata('dummy', \stdClass::class, false, false, null);
+ $request = $this->requestWithAttributes(['_controller' => ['App\\Controller\\Mine', 'method']]);
+ $this->assertTrue($resolver->supports($request, $argument));
+ $resolver->resolve($request, $argument);
+ }
+
+ private function requestWithAttributes(array $attributes)
+ {
+ $request = Request::create('/');
+ foreach ($attributes as $name => $value) {
+ $request->attributes->set($name, $value);
+ }
+
+ return $request;
+ }
+}
diff --git a/vendor/symfony/http-kernel/Tests/DataCollector/DumpDataCollectorTest.php b/vendor/symfony/http-kernel/Tests/DataCollector/DumpDataCollectorTest.php
index 76c1d96dcc..a40a482278 100644
--- a/vendor/symfony/http-kernel/Tests/DataCollector/DumpDataCollectorTest.php
+++ b/vendor/symfony/http-kernel/Tests/DataCollector/DumpDataCollectorTest.php
@@ -52,9 +52,9 @@ class DumpDataCollectorTest extends TestCase
];
$this->assertEquals($xDump, $dump);
- $this->assertStringMatchesFormat('a:3:{i:0;a:5:{s:4:"data";%c:39:"Symfony\Component\VarDumper\Cloner\Data":%a', $collector->serialize());
+ $this->assertStringMatchesFormat('%a;a:%d:{i:0;a:5:{s:4:"data";%c:39:"Symfony\Component\VarDumper\Cloner\Data":%a', serialize($collector));
$this->assertSame(0, $collector->getDumpsCount());
- $this->assertSame('a:2:{i:0;b:0;i:1;s:5:"UTF-8";}', $collector->serialize());
+ $this->assertSame("O:60:\"Symfony\Component\HttpKernel\DataCollector\DumpDataCollector\":1:{s:7:\"\0*\0data\";a:2:{i:0;b:0;i:1;s:5:\"UTF-8\";}}", serialize($collector));
}
public function testDumpWithServerConnection()
@@ -72,7 +72,7 @@ class DumpDataCollectorTest extends TestCase
ob_start();
$collector->collect(new Request(), new Response());
$this->assertEmpty(ob_get_clean());
- $this->assertStringMatchesFormat('a:3:{i:0;a:5:{s:4:"data";%c:39:"Symfony\Component\VarDumper\Cloner\Data":%a', $collector->serialize());
+ $this->assertStringMatchesFormat('%a;a:%d:{i:0;a:5:{s:4:"data";%c:39:"Symfony\Component\VarDumper\Cloner\Data":%a', serialize($collector));
}
public function testCollectDefault()
@@ -90,7 +90,7 @@ class DumpDataCollectorTest extends TestCase
$this->assertSame("DumpDataCollectorTest.php on line {$line}:\n123\n", $output);
$this->assertSame(1, $collector->getDumpsCount());
- $collector->serialize();
+ serialize($collector);
}
public function testCollectHtml()
@@ -118,7 +118,7 @@ EOTXT;
$this->assertSame($xOutput, trim($output));
$this->assertSame(1, $collector->getDumpsCount());
- $collector->serialize();
+ serialize($collector);
}
public function testFlush()
diff --git a/vendor/symfony/http-kernel/Tests/DataCollector/RequestDataCollectorTest.php b/vendor/symfony/http-kernel/Tests/DataCollector/RequestDataCollectorTest.php
index b5541610f6..42215ea0f7 100644
--- a/vendor/symfony/http-kernel/Tests/DataCollector/RequestDataCollectorTest.php
+++ b/vendor/symfony/http-kernel/Tests/DataCollector/RequestDataCollectorTest.php
@@ -22,8 +22,8 @@ use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
use Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface;
use Symfony\Component\HttpKernel\DataCollector\RequestDataCollector;
-use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
-use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
+use Symfony\Component\HttpKernel\Event\ControllerEvent;
+use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\HttpKernel\HttpKernel;
use Symfony\Component\HttpKernel\HttpKernelInterface;
@@ -206,7 +206,7 @@ class RequestDataCollectorTest extends TestCase
$kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock();
$c = new RequestDataCollector();
- $c->onKernelResponse(new FilterResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, $this->createResponse()));
+ $c->onKernelResponse(new ResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, $this->createResponse()));
$this->assertTrue($request->attributes->get('_redirected'));
}
@@ -290,7 +290,7 @@ class RequestDataCollectorTest extends TestCase
{
$resolver = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface')->getMock();
$httpKernel = new HttpKernel(new EventDispatcher(), $resolver, null, $this->getMockBuilder(ArgumentResolverInterface::class)->getMock());
- $event = new FilterControllerEvent($httpKernel, $controller, $request, HttpKernelInterface::MASTER_REQUEST);
+ $event = new ControllerEvent($httpKernel, $controller, $request, HttpKernelInterface::MASTER_REQUEST);
$collector->onKernelController($event);
}
@@ -333,4 +333,58 @@ class RequestDataCollectorTest extends TestCase
throw new \InvalidArgumentException(sprintf('Cookie named "%s" is not in response', $name));
}
+
+ /**
+ * @dataProvider provideJsonContentTypes
+ */
+ public function testIsJson($contentType, $expected)
+ {
+ $response = $this->createResponse();
+ $request = $this->createRequest();
+ $request->headers->set('Content-Type', $contentType);
+
+ $c = new RequestDataCollector();
+ $c->collect($request, $response);
+
+ $this->assertSame($expected, $c->isJsonRequest());
+ }
+
+ public function provideJsonContentTypes()
+ {
+ return [
+ ['text/csv', false],
+ ['application/json', true],
+ ['application/JSON', true],
+ ['application/hal+json', true],
+ ['application/xml+json', true],
+ ['application/xml', false],
+ ['', false],
+ ];
+ }
+
+ /**
+ * @dataProvider providePrettyJson
+ */
+ public function testGetPrettyJsonValidity($content, $expected)
+ {
+ $response = $this->createResponse();
+ $request = Request::create('/', 'POST', [], [], [], [], $content);
+
+ $c = new RequestDataCollector();
+ $c->collect($request, $response);
+
+ $this->assertSame($expected, $c->getPrettyJson());
+ }
+
+ public function providePrettyJson()
+ {
+ return [
+ ['null', 'null'],
+ ['{ "foo": "bar" }', '{
+ "foo": "bar"
+}'],
+ ['{ "abc" }', null],
+ ['', null],
+ ];
+ }
}
diff --git a/vendor/symfony/http-kernel/Tests/Debug/FileLinkFormatterTest.php b/vendor/symfony/http-kernel/Tests/Debug/FileLinkFormatterTest.php
index 5c93bd90e3..1f4d298bf3 100644
--- a/vendor/symfony/http-kernel/Tests/Debug/FileLinkFormatterTest.php
+++ b/vendor/symfony/http-kernel/Tests/Debug/FileLinkFormatterTest.php
@@ -34,18 +34,6 @@ class FileLinkFormatterTest extends TestCase
$this->assertSame("debug://open?url=file://$file&line=3", $sut->format($file, 3));
}
- public function testWhenFileLinkFormatAndRequest()
- {
- $file = __DIR__.\DIRECTORY_SEPARATOR.'file.php';
- $requestStack = new RequestStack();
- $request = new Request();
- $requestStack->push($request);
-
- $sut = new FileLinkFormatter('debug://open?url=file://%f&line=%l', $requestStack, __DIR__, '/_profiler/open?file=%f&line=%l#line%l');
-
- $this->assertSame("debug://open?url=file://$file&line=3", $sut->format($file, 3));
- }
-
public function testWhenNoFileLinkFormatAndRequest()
{
$file = __DIR__.\DIRECTORY_SEPARATOR.'file.php';
diff --git a/vendor/symfony/http-kernel/Tests/Debug/TraceableEventDispatcherTest.php b/vendor/symfony/http-kernel/Tests/Debug/TraceableEventDispatcherTest.php
index 8b8e91aeb4..ef4f4bf66a 100644
--- a/vendor/symfony/http-kernel/Tests/Debug/TraceableEventDispatcherTest.php
+++ b/vendor/symfony/http-kernel/Tests/Debug/TraceableEventDispatcherTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\HttpKernel\Tests\Debug;
use PHPUnit\Framework\TestCase;
+use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
@@ -89,10 +90,10 @@ class TraceableEventDispatcherTest extends TestCase
$called2 = true;
});
});
- $dispatcher->dispatch('my-event');
+ $dispatcher->dispatch(new Event(), 'my-event');
$this->assertTrue($called1);
$this->assertFalse($called2);
- $dispatcher->dispatch('my-event');
+ $dispatcher->dispatch(new Event(), 'my-event');
$this->assertTrue($called2);
}
@@ -104,7 +105,7 @@ class TraceableEventDispatcherTest extends TestCase
};
$eventDispatcher->addListener('foo', $listener1);
$eventDispatcher->addListener('foo', function () {});
- $eventDispatcher->dispatch('foo');
+ $eventDispatcher->dispatch(new Event(), 'foo');
$this->assertCount(1, $eventDispatcher->getListeners('foo'), 'expected listener1 to be removed');
}
diff --git a/vendor/symfony/http-kernel/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php b/vendor/symfony/http-kernel/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php
index cf685b2ae2..948311556c 100644
--- a/vendor/symfony/http-kernel/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php
+++ b/vendor/symfony/http-kernel/Tests/DependencyInjection/RegisterControllerArgumentLocatorsPassTest.php
@@ -376,6 +376,19 @@ class RegisterControllerArgumentLocatorsPassTest extends TestCase
$this->assertInstanceOf(ServiceClosureArgument::class, $locator['someArg']);
$this->assertEquals(new Reference('parent'), $locator['someArg']->getValues()[0]);
}
+
+ public function testNotTaggedControllerServiceReceivesLocatorArgument()
+ {
+ $container = new ContainerBuilder();
+ $resolver = $container->register('argument_resolver.not_tagged_controller')->addArgument([]);
+
+ $pass = new RegisterControllerArgumentLocatorsPass();
+ $pass->process($container);
+
+ $locatorArgument = $container->getDefinition('argument_resolver.not_tagged_controller')->getArgument(0);
+
+ $this->assertInstanceOf(Reference::class, $locatorArgument);
+ }
}
class RegisterTestController
diff --git a/vendor/symfony/http-kernel/Tests/DependencyInjection/RegisterLocaleAwareServicesPassTest.php b/vendor/symfony/http-kernel/Tests/DependencyInjection/RegisterLocaleAwareServicesPassTest.php
new file mode 100644
index 0000000000..aa3c6aa0c4
--- /dev/null
+++ b/vendor/symfony/http-kernel/Tests/DependencyInjection/RegisterLocaleAwareServicesPassTest.php
@@ -0,0 +1,59 @@
+<?php
+
+namespace Symfony\Component\HttpKernel\Tests\DependencyInjection;
+
+use PHPUnit\Framework\TestCase;
+use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\DependencyInjection\Reference;
+use Symfony\Component\HttpKernel\DependencyInjection\RegisterLocaleAwareServicesPass;
+use Symfony\Component\HttpKernel\EventListener\LocaleAwareListener;
+use Symfony\Contracts\Translation\LocaleAwareInterface;
+
+class RegisterLocaleAwareServicesPassTest extends TestCase
+{
+ public function testCompilerPass()
+ {
+ $container = new ContainerBuilder();
+
+ $container->register('locale_aware_listener', LocaleAwareListener::class)
+ ->setPublic(true)
+ ->setArguments([null, null]);
+
+ $container->register('some_locale_aware_service', LocaleAwareInterface::class)
+ ->setPublic(true)
+ ->addTag('kernel.locale_aware');
+
+ $container->register('another_locale_aware_service', LocaleAwareInterface::class)
+ ->setPublic(true)
+ ->addTag('kernel.locale_aware');
+
+ $container->addCompilerPass(new RegisterLocaleAwareServicesPass());
+ $container->compile();
+
+ $this->assertEquals(
+ [
+ new IteratorArgument([
+ 0 => new Reference('some_locale_aware_service'),
+ 1 => new Reference('another_locale_aware_service'),
+ ]),
+ null,
+ ],
+ $container->getDefinition('locale_aware_listener')->getArguments()
+ );
+ }
+
+ public function testListenerUnregisteredWhenNoLocaleAwareServices()
+ {
+ $container = new ContainerBuilder();
+
+ $container->register('locale_aware_listener', LocaleAwareListener::class)
+ ->setPublic(true)
+ ->setArguments([null, null]);
+
+ $container->addCompilerPass(new RegisterLocaleAwareServicesPass());
+ $container->compile();
+
+ $this->assertFalse($container->hasDefinition('locale_aware_listener'));
+ }
+}
diff --git a/vendor/symfony/http-kernel/Tests/Event/ControllerArgumentsEventTest.php b/vendor/symfony/http-kernel/Tests/Event/ControllerArgumentsEventTest.php
new file mode 100644
index 0000000000..7758a66667
--- /dev/null
+++ b/vendor/symfony/http-kernel/Tests/Event/ControllerArgumentsEventTest.php
@@ -0,0 +1,17 @@
+<?php
+
+namespace Symfony\Component\HttpKernel\Tests\Event;
+
+use PHPUnit\Framework\TestCase;
+use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpKernel\Event\ControllerArgumentsEvent;
+use Symfony\Component\HttpKernel\Tests\TestHttpKernel;
+
+class ControllerArgumentsEventTest extends TestCase
+{
+ public function testControllerArgumentsEvent()
+ {
+ $filterController = new ControllerArgumentsEvent(new TestHttpKernel(), function () {}, ['test'], new Request(), 1);
+ $this->assertEquals($filterController->getArguments(), ['test']);
+ }
+}
diff --git a/vendor/symfony/http-kernel/Tests/Event/GetResponseForExceptionEventTest.php b/vendor/symfony/http-kernel/Tests/Event/ExceptionEventTest.php
index 7242579301..6b061d3a33 100644
--- a/vendor/symfony/http-kernel/Tests/Event/GetResponseForExceptionEventTest.php
+++ b/vendor/symfony/http-kernel/Tests/Event/ExceptionEventTest.php
@@ -13,14 +13,14 @@ namespace Symfony\Component\HttpKernel\Tests\Event;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
-use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
+use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\Tests\TestHttpKernel;
-class GetResponseForExceptionEventTest extends TestCase
+class ExceptionEventTest extends TestCase
{
public function testAllowSuccessfulResponseIsFalseByDefault()
{
- $event = new GetResponseForExceptionEvent(new TestHttpKernel(), new Request(), 1, new \Exception());
+ $event = new ExceptionEvent(new TestHttpKernel(), new Request(), 1, new \Exception());
$this->assertFalse($event->isAllowingCustomResponseCode());
}
diff --git a/vendor/symfony/http-kernel/Tests/Event/FilterControllerArgumentsEventTest.php b/vendor/symfony/http-kernel/Tests/Event/FilterControllerArgumentsEventTest.php
deleted file mode 100644
index abc51ac51e..0000000000
--- a/vendor/symfony/http-kernel/Tests/Event/FilterControllerArgumentsEventTest.php
+++ /dev/null
@@ -1,17 +0,0 @@
-<?php
-
-namespace Symfony\Component\HttpKernel\Tests\Event;
-
-use PHPUnit\Framework\TestCase;
-use Symfony\Component\HttpFoundation\Request;
-use Symfony\Component\HttpKernel\Event\FilterControllerArgumentsEvent;
-use Symfony\Component\HttpKernel\Tests\TestHttpKernel;
-
-class FilterControllerArgumentsEventTest extends TestCase
-{
- public function testFilterControllerArgumentsEvent()
- {
- $filterController = new FilterControllerArgumentsEvent(new TestHttpKernel(), function () {}, ['test'], new Request(), 1);
- $this->assertEquals($filterController->getArguments(), ['test']);
- }
-}
diff --git a/vendor/symfony/http-kernel/Tests/EventListener/AddRequestFormatsListenerTest.php b/vendor/symfony/http-kernel/Tests/EventListener/AddRequestFormatsListenerTest.php
index b4ea2f955b..b8b4719206 100644
--- a/vendor/symfony/http-kernel/Tests/EventListener/AddRequestFormatsListenerTest.php
+++ b/vendor/symfony/http-kernel/Tests/EventListener/AddRequestFormatsListenerTest.php
@@ -13,6 +13,7 @@ namespace Symfony\Component\HttpKernel\Tests\EventListener;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\EventListener\AddRequestFormatsListener;
use Symfony\Component\HttpKernel\KernelEvents;
@@ -46,7 +47,7 @@ class AddRequestFormatsListenerTest extends TestCase
public function testRegisteredEvent()
{
$this->assertEquals(
- [KernelEvents::REQUEST => ['onKernelRequest', 1]],
+ [KernelEvents::REQUEST => ['onKernelRequest', 100]],
AddRequestFormatsListener::getSubscribedEvents()
);
}
@@ -54,7 +55,7 @@ class AddRequestFormatsListenerTest extends TestCase
public function testSetAdditionalFormats()
{
$request = $this->getRequestMock();
- $event = $this->getGetResponseEventMock($request);
+ $event = $this->getRequestEventMock($request);
$request->expects($this->once())
->method('setFormat')
@@ -68,10 +69,10 @@ class AddRequestFormatsListenerTest extends TestCase
return $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
}
- protected function getGetResponseEventMock(Request $request)
+ protected function getRequestEventMock(Request $request)
{
$event = $this
- ->getMockBuilder('Symfony\Component\HttpKernel\Event\GetResponseEvent')
+ ->getMockBuilder(RequestEvent::class)
->disableOriginalConstructor()
->getMock();
diff --git a/vendor/symfony/http-kernel/Tests/EventListener/DebugHandlersListenerTest.php b/vendor/symfony/http-kernel/Tests/EventListener/DebugHandlersListenerTest.php
index d9e261d35a..f1a56e537b 100644
--- a/vendor/symfony/http-kernel/Tests/EventListener/DebugHandlersListenerTest.php
+++ b/vendor/symfony/http-kernel/Tests/EventListener/DebugHandlersListenerTest.php
@@ -112,7 +112,7 @@ class DebugHandlersListenerTest extends TestCase
set_error_handler([$eHandler, 'handleError']);
set_exception_handler([$eHandler, 'handleException']);
try {
- $dispatcher->dispatch(ConsoleEvents::COMMAND, $event);
+ $dispatcher->dispatch($event, ConsoleEvents::COMMAND);
} catch (\Exception $exception) {
}
restore_exception_handler();
diff --git a/vendor/symfony/http-kernel/Tests/EventListener/DisallowRobotsIndexingListenerTest.php b/vendor/symfony/http-kernel/Tests/EventListener/DisallowRobotsIndexingListenerTest.php
new file mode 100644
index 0000000000..53b317b761
--- /dev/null
+++ b/vendor/symfony/http-kernel/Tests/EventListener/DisallowRobotsIndexingListenerTest.php
@@ -0,0 +1,47 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\HttpKernel\Tests\EventListener;
+
+use PHPUnit\Framework\TestCase;
+use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpFoundation\Response;
+use Symfony\Component\HttpKernel\Event\ResponseEvent;
+use Symfony\Component\HttpKernel\EventListener\DisallowRobotsIndexingListener;
+use Symfony\Component\HttpKernel\HttpKernelInterface;
+use Symfony\Component\HttpKernel\KernelInterface;
+
+class DisallowRobotsIndexingListenerTest extends TestCase
+{
+ /**
+ * @dataProvider provideResponses
+ */
+ public function testInvoke(?string $expected, Response $response): void
+ {
+ $listener = new DisallowRobotsIndexingListener();
+
+ $event = new ResponseEvent($this->createMock(HttpKernelInterface::class), $this->createMock(Request::class), KernelInterface::MASTER_REQUEST, $response);
+
+ $listener->onResponse($event);
+
+ $this->assertSame($expected, $response->headers->get('X-Robots-Tag'), 'Header doesn\'t match expectations');
+ }
+
+ public function provideResponses(): iterable
+ {
+ yield 'No header' => ['noindex', new Response()];
+
+ yield 'Header already set' => [
+ 'something else',
+ new Response('', 204, ['X-Robots-Tag' => 'something else']),
+ ];
+ }
+}
diff --git a/vendor/symfony/http-kernel/Tests/EventListener/ExceptionListenerTest.php b/vendor/symfony/http-kernel/Tests/EventListener/ExceptionListenerTest.php
index b7224ddcea..18763c881b 100644
--- a/vendor/symfony/http-kernel/Tests/EventListener/ExceptionListenerTest.php
+++ b/vendor/symfony/http-kernel/Tests/EventListener/ExceptionListenerTest.php
@@ -15,8 +15,8 @@ use PHPUnit\Framework\TestCase;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
-use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
-use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
+use Symfony\Component\HttpKernel\Event\ExceptionEvent;
+use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\HttpKernel\EventListener\ExceptionListener;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\KernelEvents;
@@ -103,8 +103,8 @@ class ExceptionListenerTest extends TestCase
$request = new Request();
$exception = new \Exception('foo');
- $event = new GetResponseForExceptionEvent(new TestKernel(), $request, HttpKernelInterface::MASTER_REQUEST, $exception);
- $event2 = new GetResponseForExceptionEvent(new TestKernelThatThrowsException(), $request, HttpKernelInterface::MASTER_REQUEST, $exception);
+ $event = new ExceptionEvent(new TestKernel(), $request, HttpKernelInterface::MASTER_REQUEST, $exception);
+ $event2 = new ExceptionEvent(new TestKernelThatThrowsException(), $request, HttpKernelInterface::MASTER_REQUEST, $exception);
return [
[$event, $event2],
@@ -123,7 +123,7 @@ class ExceptionListenerTest extends TestCase
$request = Request::create('/');
$request->setRequestFormat('xml');
- $event = new GetResponseForExceptionEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, new \Exception('foo'));
+ $event = new ExceptionEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, new \Exception('foo'));
$listener->onKernelException($event);
$response = $event->getResponse();
@@ -143,14 +143,14 @@ class ExceptionListenerTest extends TestCase
$dispatcher->addSubscriber($listener);
$request = Request::create('/');
- $event = new GetResponseForExceptionEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, new \Exception('foo'));
- $dispatcher->dispatch(KernelEvents::EXCEPTION, $event);
+ $event = new ExceptionEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, new \Exception('foo'));
+ $dispatcher->dispatch($event, KernelEvents::EXCEPTION);
$response = new Response('', 200, ['content-security-policy' => "style-src 'self'"]);
$this->assertTrue($response->headers->has('content-security-policy'));
- $event = new FilterResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, $response);
- $dispatcher->dispatch(KernelEvents::RESPONSE, $event);
+ $event = new ResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, $response);
+ $dispatcher->dispatch($event, KernelEvents::RESPONSE);
$this->assertFalse($response->headers->has('content-security-policy'), 'CSP header has been removed');
$this->assertFalse($dispatcher->hasListeners(KernelEvents::RESPONSE), 'CSP removal listener has been removed');
@@ -166,7 +166,7 @@ class ExceptionListenerTest extends TestCase
return $controller();
}));
$request = Request::create('/');
- $event = new GetResponseForExceptionEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, new \Exception('foo'));
+ $event = new ExceptionEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, new \Exception('foo'));
$listener->onKernelException($event);
$this->assertNull($event->getResponse());
diff --git a/vendor/symfony/http-kernel/Tests/EventListener/FragmentListenerTest.php b/vendor/symfony/http-kernel/Tests/EventListener/FragmentListenerTest.php
index 6408b1b21c..40da65d240 100644
--- a/vendor/symfony/http-kernel/Tests/EventListener/FragmentListenerTest.php
+++ b/vendor/symfony/http-kernel/Tests/EventListener/FragmentListenerTest.php
@@ -13,7 +13,7 @@ namespace Symfony\Component\HttpKernel\Tests\EventListener;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
-use Symfony\Component\HttpKernel\Event\GetResponseEvent;
+use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\EventListener\FragmentListener;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\UriSigner;
@@ -25,7 +25,7 @@ class FragmentListenerTest extends TestCase
$request = Request::create('http://example.com/foo?_path=foo%3Dbar%26_controller%3Dfoo');
$listener = new FragmentListener(new UriSigner('foo'));
- $event = $this->createGetResponseEvent($request);
+ $event = $this->createRequestEvent($request);
$expected = $request->attributes->all();
@@ -41,7 +41,7 @@ class FragmentListenerTest extends TestCase
$request->attributes->set('_controller', 'bar');
$listener = new FragmentListener(new UriSigner('foo'));
- $event = $this->createGetResponseEvent($request, HttpKernelInterface::SUB_REQUEST);
+ $event = $this->createRequestEvent($request, HttpKernelInterface::SUB_REQUEST);
$expected = $request->attributes->all();
@@ -58,7 +58,7 @@ class FragmentListenerTest extends TestCase
$request = Request::create('http://example.com/_fragment', 'POST');
$listener = new FragmentListener(new UriSigner('foo'));
- $event = $this->createGetResponseEvent($request);
+ $event = $this->createRequestEvent($request);
$listener->onKernelRequest($event);
}
@@ -71,7 +71,7 @@ class FragmentListenerTest extends TestCase
$request = Request::create('http://example.com/_fragment', 'GET', [], [], [], ['REMOTE_ADDR' => '10.0.0.1']);
$listener = new FragmentListener(new UriSigner('foo'));
- $event = $this->createGetResponseEvent($request);
+ $event = $this->createRequestEvent($request);
$listener->onKernelRequest($event);
}
@@ -82,7 +82,7 @@ class FragmentListenerTest extends TestCase
$request = Request::create($signer->sign('http://example.com/_fragment?_path=foo%3Dbar%26_controller%3Dfoo'), 'GET', [], [], [], ['REMOTE_ADDR' => '10.0.0.1']);
$listener = new FragmentListener($signer);
- $event = $this->createGetResponseEvent($request);
+ $event = $this->createRequestEvent($request);
$listener->onKernelRequest($event);
@@ -95,7 +95,7 @@ class FragmentListenerTest extends TestCase
$request = Request::create('http://example.com/_fragment?_path=foo%3Dbar%26_controller%3Dfoo');
$listener = new FragmentListener(new UriSigner('foo'));
- $event = $this->createGetResponseEvent($request, HttpKernelInterface::SUB_REQUEST);
+ $event = $this->createRequestEvent($request, HttpKernelInterface::SUB_REQUEST);
$listener->onKernelRequest($event);
@@ -108,15 +108,15 @@ class FragmentListenerTest extends TestCase
$request = Request::create($signer->sign('http://example.com/_fragment?_path=foo%3Dbar'), 'GET', [], [], [], ['REMOTE_ADDR' => '10.0.0.1']);
$listener = new FragmentListener($signer);
- $event = $this->createGetResponseEvent($request);
+ $event = $this->createRequestEvent($request);
$listener->onKernelRequest($event);
$this->assertFalse($request->query->has('_path'));
}
- private function createGetResponseEvent(Request $request, $requestType = HttpKernelInterface::MASTER_REQUEST)
+ private function createRequestEvent(Request $request, $requestType = HttpKernelInterface::MASTER_REQUEST)
{
- return new GetResponseEvent($this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), $request, $requestType);
+ return new RequestEvent($this->getMockBuilder(HttpKernelInterface::class)->getMock(), $request, $requestType);
}
}
diff --git a/vendor/symfony/http-kernel/Tests/EventListener/LocaleAwareListenerTest.php b/vendor/symfony/http-kernel/Tests/EventListener/LocaleAwareListenerTest.php
new file mode 100644
index 0000000000..489b02151c
--- /dev/null
+++ b/vendor/symfony/http-kernel/Tests/EventListener/LocaleAwareListenerTest.php
@@ -0,0 +1,119 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\HttpKernel\Tests\EventListener;
+
+use PHPUnit\Framework\TestCase;
+use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpFoundation\RequestStack;
+use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
+use Symfony\Component\HttpKernel\Event\RequestEvent;
+use Symfony\Component\HttpKernel\EventListener\LocaleAwareListener;
+use Symfony\Component\HttpKernel\HttpKernelInterface;
+use Symfony\Contracts\Translation\LocaleAwareInterface;
+
+class LocaleAwareListenerTest extends TestCase
+{
+ private $listener;
+ private $localeAwareService;
+ private $requestStack;
+
+ protected function setUp()
+ {
+ $this->localeAwareService = $this->getMockBuilder(LocaleAwareInterface::class)->getMock();
+ $this->requestStack = new RequestStack();
+ $this->listener = new LocaleAwareListener(new \ArrayIterator([$this->localeAwareService]), $this->requestStack);
+ }
+
+ public function testLocaleIsSetInOnKernelRequest()
+ {
+ $this->localeAwareService
+ ->expects($this->once())
+ ->method('setLocale')
+ ->with($this->equalTo('fr'));
+
+ $event = new RequestEvent($this->createHttpKernel(), $this->createRequest('fr'), HttpKernelInterface::MASTER_REQUEST);
+ $this->listener->onKernelRequest($event);
+ }
+
+ public function testDefaultLocaleIsUsedOnExceptionsInOnKernelRequest()
+ {
+ $this->localeAwareService
+ ->expects($this->at(0))
+ ->method('setLocale')
+ ->will($this->throwException(new \InvalidArgumentException()));
+ $this->localeAwareService
+ ->expects($this->at(1))
+ ->method('setLocale')
+ ->with($this->equalTo('en'));
+
+ $event = new RequestEvent($this->createHttpKernel(), $this->createRequest('fr'), HttpKernelInterface::MASTER_REQUEST);
+ $this->listener->onKernelRequest($event);
+ }
+
+ public function testLocaleIsSetInOnKernelFinishRequestWhenParentRequestExists()
+ {
+ $this->localeAwareService
+ ->expects($this->once())
+ ->method('setLocale')
+ ->with($this->equalTo('fr'));
+
+ $this->requestStack->push($this->createRequest('fr'));
+ $this->requestStack->push($subRequest = $this->createRequest('de'));
+
+ $event = new FinishRequestEvent($this->createHttpKernel(), $subRequest, HttpKernelInterface::SUB_REQUEST);
+ $this->listener->onKernelFinishRequest($event);
+ }
+
+ public function testLocaleIsSetToDefaultOnKernelFinishRequestWhenParentRequestDoesNotExist()
+ {
+ $this->localeAwareService
+ ->expects($this->once())
+ ->method('setLocale')
+ ->with($this->equalTo('en'));
+
+ $this->requestStack->push($subRequest = $this->createRequest('de'));
+
+ $event = new FinishRequestEvent($this->createHttpKernel(), $subRequest, HttpKernelInterface::SUB_REQUEST);
+ $this->listener->onKernelFinishRequest($event);
+ }
+
+ public function testDefaultLocaleIsUsedOnExceptionsInOnKernelFinishRequest()
+ {
+ $this->localeAwareService
+ ->expects($this->at(0))
+ ->method('setLocale')
+ ->will($this->throwException(new \InvalidArgumentException()));
+ $this->localeAwareService
+ ->expects($this->at(1))
+ ->method('setLocale')
+ ->with($this->equalTo('en'));
+
+ $this->requestStack->push($this->createRequest('fr'));
+ $this->requestStack->push($subRequest = $this->createRequest('de'));
+
+ $event = new FinishRequestEvent($this->createHttpKernel(), $subRequest, HttpKernelInterface::SUB_REQUEST);
+ $this->listener->onKernelFinishRequest($event);
+ }
+
+ private function createHttpKernel()
+ {
+ return $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
+ }
+
+ private function createRequest($locale)
+ {
+ $request = new Request();
+ $request->setLocale($locale);
+
+ return $request;
+ }
+}
diff --git a/vendor/symfony/http-kernel/Tests/EventListener/LocaleListenerTest.php b/vendor/symfony/http-kernel/Tests/EventListener/LocaleListenerTest.php
index 1cf4b72c69..1e9fbe23b3 100644
--- a/vendor/symfony/http-kernel/Tests/EventListener/LocaleListenerTest.php
+++ b/vendor/symfony/http-kernel/Tests/EventListener/LocaleListenerTest.php
@@ -12,10 +12,12 @@
namespace Symfony\Component\HttpKernel\Tests\EventListener;
use PHPUnit\Framework\TestCase;
+use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Request;
-use Symfony\Component\HttpKernel\Event\GetResponseEvent;
+use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\EventListener\LocaleListener;
use Symfony\Component\HttpKernel\HttpKernelInterface;
+use Symfony\Component\HttpKernel\KernelEvents;
class LocaleListenerTest extends TestCase
{
@@ -26,12 +28,28 @@ class LocaleListenerTest extends TestCase
$this->requestStack = $this->getMockBuilder('Symfony\Component\HttpFoundation\RequestStack')->disableOriginalConstructor()->getMock();
}
- public function testDefaultLocaleWithoutSession()
+ public function testIsAnEventSubscriber()
+ {
+ $this->assertInstanceOf(EventSubscriberInterface::class, new LocaleListener($this->requestStack));
+ }
+
+ public function testRegisteredEvent()
+ {
+ $this->assertEquals(
+ [
+ KernelEvents::REQUEST => [['setDefaultLocale', 100], ['onKernelRequest', 16]],
+ KernelEvents::FINISH_REQUEST => [['onKernelFinishRequest', 0]],
+ ],
+ LocaleListener::getSubscribedEvents()
+ );
+ }
+
+ public function testDefaultLocale()
{
$listener = new LocaleListener($this->requestStack, 'fr');
$event = $this->getEvent($request = Request::create('/'));
- $listener->onKernelRequest($event);
+ $listener->setDefaultLocale($event);
$this->assertEquals('fr', $request->getLocale());
}
@@ -95,8 +113,8 @@ class LocaleListenerTest extends TestCase
$this->assertEquals('de', $request->getLocale());
}
- private function getEvent(Request $request)
+ private function getEvent(Request $request): RequestEvent
{
- return new GetResponseEvent($this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), $request, HttpKernelInterface::MASTER_REQUEST);
+ return new RequestEvent($this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock(), $request, HttpKernelInterface::MASTER_REQUEST);
}
}
diff --git a/vendor/symfony/http-kernel/Tests/EventListener/ProfilerListenerTest.php b/vendor/symfony/http-kernel/Tests/EventListener/ProfilerListenerTest.php
index 392aa2fc35..6e73d0e9b0 100644
--- a/vendor/symfony/http-kernel/Tests/EventListener/ProfilerListenerTest.php
+++ b/vendor/symfony/http-kernel/Tests/EventListener/ProfilerListenerTest.php
@@ -13,9 +13,9 @@ namespace Symfony\Component\HttpKernel\Tests\EventListener;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\RequestStack;
-use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
-use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
-use Symfony\Component\HttpKernel\Event\PostResponseEvent;
+use Symfony\Component\HttpKernel\Event\ExceptionEvent;
+use Symfony\Component\HttpKernel\Event\ResponseEvent;
+use Symfony\Component\HttpKernel\Event\TerminateEvent;
use Symfony\Component\HttpKernel\EventListener\ProfilerListener;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Kernel;
@@ -59,12 +59,12 @@ class ProfilerListenerTest extends TestCase
$listener = new ProfilerListener($profiler, $requestStack, null, $onlyException);
// master request
- $listener->onKernelResponse(new FilterResponseEvent($kernel, $masterRequest, Kernel::MASTER_REQUEST, $response));
+ $listener->onKernelResponse(new ResponseEvent($kernel, $masterRequest, Kernel::MASTER_REQUEST, $response));
// sub request
- $listener->onKernelException(new GetResponseForExceptionEvent($kernel, $subRequest, Kernel::SUB_REQUEST, new HttpException(404)));
- $listener->onKernelResponse(new FilterResponseEvent($kernel, $subRequest, Kernel::SUB_REQUEST, $response));
+ $listener->onKernelException(new ExceptionEvent($kernel, $subRequest, Kernel::SUB_REQUEST, new HttpException(404)));
+ $listener->onKernelResponse(new ResponseEvent($kernel, $subRequest, Kernel::SUB_REQUEST, $response));
- $listener->onKernelTerminate(new PostResponseEvent($kernel, $masterRequest, $response));
+ $listener->onKernelTerminate(new TerminateEvent($kernel, $masterRequest, $response));
}
}
diff --git a/vendor/symfony/http-kernel/Tests/EventListener/ResponseListenerTest.php b/vendor/symfony/http-kernel/Tests/EventListener/ResponseListenerTest.php
index aeab68f3e9..fbb2512c53 100644
--- a/vendor/symfony/http-kernel/Tests/EventListener/ResponseListenerTest.php
+++ b/vendor/symfony/http-kernel/Tests/EventListener/ResponseListenerTest.php
@@ -15,7 +15,7 @@ use PHPUnit\Framework\TestCase;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
-use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
+use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\HttpKernel\EventListener\ResponseListener;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\KernelEvents;
@@ -45,8 +45,8 @@ class ResponseListenerTest extends TestCase
{
$response = new Response('foo');
- $event = new FilterResponseEvent($this->kernel, new Request(), HttpKernelInterface::SUB_REQUEST, $response);
- $this->dispatcher->dispatch(KernelEvents::RESPONSE, $event);
+ $event = new ResponseEvent($this->kernel, new Request(), HttpKernelInterface::SUB_REQUEST, $response);
+ $this->dispatcher->dispatch($event, KernelEvents::RESPONSE);
$this->assertEquals('', $event->getResponse()->headers->get('content-type'));
}
@@ -58,8 +58,8 @@ class ResponseListenerTest extends TestCase
$response = new Response('foo');
- $event = new FilterResponseEvent($this->kernel, Request::create('/'), HttpKernelInterface::MASTER_REQUEST, $response);
- $this->dispatcher->dispatch(KernelEvents::RESPONSE, $event);
+ $event = new ResponseEvent($this->kernel, Request::create('/'), HttpKernelInterface::MASTER_REQUEST, $response);
+ $this->dispatcher->dispatch($event, KernelEvents::RESPONSE);
$this->assertEquals('ISO-8859-15', $response->getCharset());
}
@@ -72,8 +72,8 @@ class ResponseListenerTest extends TestCase
$response = new Response('foo');
$response->setCharset('ISO-8859-1');
- $event = new FilterResponseEvent($this->kernel, Request::create('/'), HttpKernelInterface::MASTER_REQUEST, $response);
- $this->dispatcher->dispatch(KernelEvents::RESPONSE, $event);
+ $event = new ResponseEvent($this->kernel, Request::create('/'), HttpKernelInterface::MASTER_REQUEST, $response);
+ $this->dispatcher->dispatch($event, KernelEvents::RESPONSE);
$this->assertEquals('ISO-8859-1', $response->getCharset());
}
@@ -87,8 +87,8 @@ class ResponseListenerTest extends TestCase
$request = Request::create('/');
$request->setRequestFormat('application/json');
- $event = new FilterResponseEvent($this->kernel, $request, HttpKernelInterface::MASTER_REQUEST, $response);
- $this->dispatcher->dispatch(KernelEvents::RESPONSE, $event);
+ $event = new ResponseEvent($this->kernel, $request, HttpKernelInterface::MASTER_REQUEST, $response);
+ $this->dispatcher->dispatch($event, KernelEvents::RESPONSE);
$this->assertEquals('ISO-8859-15', $response->getCharset());
}
diff --git a/vendor/symfony/http-kernel/Tests/EventListener/RouterListenerTest.php b/vendor/symfony/http-kernel/Tests/EventListener/RouterListenerTest.php
index c27b341300..7621ed8e65 100644
--- a/vendor/symfony/http-kernel/Tests/EventListener/RouterListenerTest.php
+++ b/vendor/symfony/http-kernel/Tests/EventListener/RouterListenerTest.php
@@ -18,7 +18,7 @@ use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Controller\ArgumentResolver;
use Symfony\Component\HttpKernel\Controller\ControllerResolver;
-use Symfony\Component\HttpKernel\Event\GetResponseEvent;
+use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\EventListener\ExceptionListener;
use Symfony\Component\HttpKernel\EventListener\RouterListener;
use Symfony\Component\HttpKernel\EventListener\ValidateRequestListener;
@@ -52,7 +52,7 @@ class RouterListenerTest extends TestCase
->will($this->returnValue($context));
$listener = new RouterListener($urlMatcher, $this->requestStack);
- $event = $this->createGetResponseEventForUri($uri);
+ $event = $this->createRequestEventForUri($uri);
$listener->onKernelRequest($event);
$this->assertEquals($expectedHttpPort, $context->getHttpPort());
@@ -70,13 +70,13 @@ class RouterListenerTest extends TestCase
];
}
- private function createGetResponseEventForUri(string $uri): GetResponseEvent
+ private function createRequestEventForUri(string $uri): RequestEvent
{
- $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
+ $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock();
$request = Request::create($uri);
$request->attributes->set('_controller', null); // Prevents going in to routing process
- return new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST);
+ return new RequestEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST);
}
/**
@@ -89,9 +89,9 @@ class RouterListenerTest extends TestCase
public function testRequestMatcher()
{
- $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
+ $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock();
$request = Request::create('http://localhost/');
- $event = new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST);
+ $event = new RequestEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST);
$requestMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock();
$requestMatcher->expects($this->once())
@@ -105,9 +105,9 @@ class RouterListenerTest extends TestCase
public function testSubRequestWithDifferentMethod()
{
- $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
+ $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock();
$request = Request::create('http://localhost/', 'post');
- $event = new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST);
+ $event = new RequestEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST);
$requestMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock();
$requestMatcher->expects($this->any())
@@ -121,9 +121,9 @@ class RouterListenerTest extends TestCase
$listener->onKernelRequest($event);
// sub-request with another HTTP method
- $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
+ $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock();
$request = Request::create('http://localhost/', 'get');
- $event = new GetResponseEvent($kernel, $request, HttpKernelInterface::SUB_REQUEST);
+ $event = new RequestEvent($kernel, $request, HttpKernelInterface::SUB_REQUEST);
$listener->onKernelRequest($event);
@@ -145,11 +145,11 @@ class RouterListenerTest extends TestCase
->method('info')
->with($this->equalTo($log), $this->equalTo($parameters));
- $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
+ $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock();
$request = Request::create('http://localhost/');
$listener = new RouterListener($requestMatcher, $this->requestStack, new RequestContext(), $logger);
- $listener->onKernelRequest(new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST));
+ $listener->onKernelRequest(new RequestEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST));
}
public function getLoggingParameterData()
@@ -209,9 +209,9 @@ class RouterListenerTest extends TestCase
*/
public function testRequestWithBadHost()
{
- $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
+ $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock();
$request = Request::create('http://bad host %22/');
- $event = new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST);
+ $event = new RequestEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST);
$requestMatcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\RequestMatcherInterface')->getMock();
diff --git a/vendor/symfony/http-kernel/Tests/EventListener/SaveSessionListenerTest.php b/vendor/symfony/http-kernel/Tests/EventListener/SaveSessionListenerTest.php
index a903fd5891..6cdd7476c9 100644
--- a/vendor/symfony/http-kernel/Tests/EventListener/SaveSessionListenerTest.php
+++ b/vendor/symfony/http-kernel/Tests/EventListener/SaveSessionListenerTest.php
@@ -15,7 +15,7 @@ use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
-use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
+use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\HttpKernel\EventListener\SaveSessionListener;
use Symfony\Component\HttpKernel\HttpKernelInterface;
@@ -27,7 +27,7 @@ class SaveSessionListenerTest extends TestCase
public function testOnlyTriggeredOnMasterRequest()
{
$listener = new SaveSessionListener();
- $event = $this->getMockBuilder(FilterResponseEvent::class)->disableOriginalConstructor()->getMock();
+ $event = $this->getMockBuilder(ResponseEvent::class)->disableOriginalConstructor()->getMock();
$event->expects($this->once())->method('isMasterRequest')->willReturn(false);
$event->expects($this->never())->method('getRequest');
@@ -47,6 +47,6 @@ class SaveSessionListenerTest extends TestCase
$request = new Request();
$request->setSession($session);
$response = new Response();
- $listener->onKernelResponse(new FilterResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, $response));
+ $listener->onKernelResponse(new ResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, $response));
}
}
diff --git a/vendor/symfony/http-kernel/Tests/EventListener/SessionListenerTest.php b/vendor/symfony/http-kernel/Tests/EventListener/SessionListenerTest.php
index f931f6dacd..5073e8e3c2 100644
--- a/vendor/symfony/http-kernel/Tests/EventListener/SessionListenerTest.php
+++ b/vendor/symfony/http-kernel/Tests/EventListener/SessionListenerTest.php
@@ -19,9 +19,9 @@ use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
-use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
-use Symfony\Component\HttpKernel\Event\GetResponseEvent;
+use Symfony\Component\HttpKernel\Event\RequestEvent;
+use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\HttpKernel\EventListener\AbstractSessionListener;
use Symfony\Component\HttpKernel\EventListener\SessionListener;
use Symfony\Component\HttpKernel\HttpKernelInterface;
@@ -31,7 +31,7 @@ class SessionListenerTest extends TestCase
public function testOnlyTriggeredOnMasterRequest()
{
$listener = $this->getMockForAbstractClass(AbstractSessionListener::class);
- $event = $this->getMockBuilder(GetResponseEvent::class)->disableOriginalConstructor()->getMock();
+ $event = $this->getMockBuilder(RequestEvent::class)->disableOriginalConstructor()->getMock();
$event->expects($this->once())->method('isMasterRequest')->willReturn(false);
$event->expects($this->never())->method('getRequest');
@@ -57,7 +57,7 @@ class SessionListenerTest extends TestCase
$request = new Request();
$listener = new SessionListener($container);
- $event = $this->getMockBuilder(GetResponseEvent::class)->disableOriginalConstructor()->getMock();
+ $event = $this->getMockBuilder(RequestEvent::class)->disableOriginalConstructor()->getMock();
$event->expects($this->once())->method('isMasterRequest')->willReturn(true);
$event->expects($this->once())->method('getRequest')->willReturn($request);
@@ -79,10 +79,10 @@ class SessionListenerTest extends TestCase
$kernel = $this->getMockBuilder(HttpKernelInterface::class)->disableOriginalConstructor()->getMock();
$request = new Request();
- $listener->onKernelRequest(new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST));
+ $listener->onKernelRequest(new RequestEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST));
$response = new Response();
- $listener->onKernelResponse(new FilterResponseEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response));
+ $listener->onKernelResponse(new ResponseEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response));
$this->assertTrue($response->headers->hasCacheControlDirective('private'));
$this->assertTrue($response->headers->hasCacheControlDirective('must-revalidate'));
@@ -102,12 +102,12 @@ class SessionListenerTest extends TestCase
$kernel = $this->getMockBuilder(HttpKernelInterface::class)->disableOriginalConstructor()->getMock();
$request = new Request();
- $listener->onKernelRequest(new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST));
+ $listener->onKernelRequest(new RequestEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST));
$response = new Response();
$response->setSharedMaxAge(60);
$response->headers->set(AbstractSessionListener::NO_AUTO_CACHE_CONTROL_HEADER, 'true');
- $listener->onKernelResponse(new FilterResponseEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response));
+ $listener->onKernelResponse(new ResponseEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response));
$this->assertTrue($response->headers->hasCacheControlDirective('public'));
$this->assertFalse($response->headers->hasCacheControlDirective('private'));
@@ -128,7 +128,7 @@ class SessionListenerTest extends TestCase
]);
$listener = new SessionListener($container);
- $listener->onKernelResponse(new FilterResponseEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response));
+ $listener->onKernelResponse(new ResponseEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response));
$this->assertTrue($response->headers->hasCacheControlDirective('public'));
$this->assertFalse($response->headers->hasCacheControlDirective('private'));
$this->assertFalse($response->headers->hasCacheControlDirective('must-revalidate'));
@@ -151,20 +151,20 @@ class SessionListenerTest extends TestCase
$request = new Request();
$response = new Response();
$response->setCache(['public' => true, 'max_age' => '30']);
- $listener->onKernelRequest(new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST));
+ $listener->onKernelRequest(new RequestEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST));
$this->assertTrue($request->hasSession());
$subRequest = clone $request;
$this->assertSame($request->getSession(), $subRequest->getSession());
- $listener->onKernelRequest(new GetResponseEvent($kernel, $subRequest, HttpKernelInterface::MASTER_REQUEST));
- $listener->onKernelResponse(new FilterResponseEvent($kernel, $subRequest, HttpKernelInterface::MASTER_REQUEST, $response));
+ $listener->onKernelRequest(new RequestEvent($kernel, $subRequest, HttpKernelInterface::MASTER_REQUEST));
+ $listener->onKernelResponse(new ResponseEvent($kernel, $subRequest, HttpKernelInterface::MASTER_REQUEST, $response));
$listener->onFinishRequest(new FinishRequestEvent($kernel, $subRequest, HttpKernelInterface::MASTER_REQUEST));
$this->assertFalse($response->headers->hasCacheControlDirective('private'));
$this->assertFalse($response->headers->hasCacheControlDirective('must-revalidate'));
$this->assertSame('30', $response->headers->getCacheControlDirective('max-age'));
- $listener->onKernelResponse(new FilterResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, $response));
+ $listener->onKernelResponse(new ResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, $response));
$this->assertTrue($response->headers->hasCacheControlDirective('private'));
$this->assertTrue($response->headers->hasCacheControlDirective('must-revalidate'));
diff --git a/vendor/symfony/http-kernel/Tests/EventListener/SurrogateListenerTest.php b/vendor/symfony/http-kernel/Tests/EventListener/SurrogateListenerTest.php
index 66e119f123..fc51de252e 100644
--- a/vendor/symfony/http-kernel/Tests/EventListener/SurrogateListenerTest.php
+++ b/vendor/symfony/http-kernel/Tests/EventListener/SurrogateListenerTest.php
@@ -15,7 +15,7 @@ use PHPUnit\Framework\TestCase;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
-use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
+use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\HttpKernel\EventListener\SurrogateListener;
use Symfony\Component\HttpKernel\HttpCache\Esi;
use Symfony\Component\HttpKernel\HttpKernelInterface;
@@ -31,8 +31,8 @@ class SurrogateListenerTest extends TestCase
$listener = new SurrogateListener(new Esi());
$dispatcher->addListener(KernelEvents::RESPONSE, [$listener, 'onKernelResponse']);
- $event = new FilterResponseEvent($kernel, new Request(), HttpKernelInterface::SUB_REQUEST, $response);
- $dispatcher->dispatch(KernelEvents::RESPONSE, $event);
+ $event = new ResponseEvent($kernel, new Request(), HttpKernelInterface::SUB_REQUEST, $response);
+ $dispatcher->dispatch($event, KernelEvents::RESPONSE);
$this->assertEquals('', $event->getResponse()->headers->get('Surrogate-Control'));
}
@@ -45,8 +45,8 @@ class SurrogateListenerTest extends TestCase
$listener = new SurrogateListener(new Esi());
$dispatcher->addListener(KernelEvents::RESPONSE, [$listener, 'onKernelResponse']);
- $event = new FilterResponseEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response);
- $dispatcher->dispatch(KernelEvents::RESPONSE, $event);
+ $event = new ResponseEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response);
+ $dispatcher->dispatch($event, KernelEvents::RESPONSE);
$this->assertEquals('content="ESI/1.0"', $event->getResponse()->headers->get('Surrogate-Control'));
}
@@ -59,8 +59,8 @@ class SurrogateListenerTest extends TestCase
$listener = new SurrogateListener(new Esi());
$dispatcher->addListener(KernelEvents::RESPONSE, [$listener, 'onKernelResponse']);
- $event = new FilterResponseEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response);
- $dispatcher->dispatch(KernelEvents::RESPONSE, $event);
+ $event = new ResponseEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response);
+ $dispatcher->dispatch($event, KernelEvents::RESPONSE);
$this->assertEquals('', $event->getResponse()->headers->get('Surrogate-Control'));
}
diff --git a/vendor/symfony/http-kernel/Tests/EventListener/TestSessionListenerTest.php b/vendor/symfony/http-kernel/Tests/EventListener/TestSessionListenerTest.php
index 9f6a5ef759..0eaa63f06a 100644
--- a/vendor/symfony/http-kernel/Tests/EventListener/TestSessionListenerTest.php
+++ b/vendor/symfony/http-kernel/Tests/EventListener/TestSessionListenerTest.php
@@ -15,8 +15,8 @@ use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
-use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
-use Symfony\Component\HttpKernel\Event\GetResponseEvent;
+use Symfony\Component\HttpKernel\Event\RequestEvent;
+use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\HttpKernel\EventListener\SessionListener;
use Symfony\Component\HttpKernel\EventListener\TestSessionListener;
use Symfony\Component\HttpKernel\HttpKernelInterface;
@@ -95,9 +95,9 @@ class TestSessionListenerTest extends TestCase
$this->sessionIsEmpty();
$this->fixSessionId('456');
- $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
+ $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock();
$request = Request::create('/', 'GET', [], ['MOCKSESSID' => '123']);
- $event = new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST);
+ $event = new RequestEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST);
$this->listener->onKernelRequest($event);
$response = $this->filterResponse(new Request(), HttpKernelInterface::MASTER_REQUEST);
@@ -114,9 +114,9 @@ class TestSessionListenerTest extends TestCase
$this->sessionIsEmpty();
$this->fixSessionId('456');
- $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
+ $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock();
$request = Request::create('/', 'GET', [], ['MOCKSESSID' => '123']);
- $event = new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST);
+ $event = new RequestEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST);
$this->listener->onKernelRequest($event);
$response = new Response('', 200, ['Set-Cookie' => $existing]);
@@ -145,8 +145,8 @@ class TestSessionListenerTest extends TestCase
public function testDoesNotThrowIfRequestDoesNotHaveASession()
{
- $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
- $event = new FilterResponseEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, new Response());
+ $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock();
+ $event = new ResponseEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, new Response());
$this->listener->onKernelResponse($event);
@@ -157,8 +157,8 @@ class TestSessionListenerTest extends TestCase
{
$request->setSession($this->session);
$response = $response ?: new Response();
- $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
- $event = new FilterResponseEvent($kernel, $request, $type, $response);
+ $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock();
+ $event = new ResponseEvent($kernel, $request, $type, $response);
$this->listener->onKernelResponse($event);
diff --git a/vendor/symfony/http-kernel/Tests/EventListener/TranslatorListenerTest.php b/vendor/symfony/http-kernel/Tests/EventListener/TranslatorListenerTest.php
index c75e7b980f..1627a2b191 100644
--- a/vendor/symfony/http-kernel/Tests/EventListener/TranslatorListenerTest.php
+++ b/vendor/symfony/http-kernel/Tests/EventListener/TranslatorListenerTest.php
@@ -14,11 +14,14 @@ namespace Symfony\Component\HttpKernel\Tests\EventListener;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
-use Symfony\Component\HttpKernel\Event\GetResponseEvent;
+use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\EventListener\TranslatorListener;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Contracts\Translation\LocaleAwareInterface;
+/**
+ * @group legacy
+ */
class TranslatorListenerTest extends TestCase
{
private $listener;
@@ -39,7 +42,7 @@ class TranslatorListenerTest extends TestCase
->method('setLocale')
->with($this->equalTo('fr'));
- $event = new GetResponseEvent($this->createHttpKernel(), $this->createRequest('fr'), HttpKernelInterface::MASTER_REQUEST);
+ $event = new RequestEvent($this->createHttpKernel(), $this->createRequest('fr'), HttpKernelInterface::MASTER_REQUEST);
$this->listener->onKernelRequest($event);
}
@@ -54,7 +57,7 @@ class TranslatorListenerTest extends TestCase
->method('setLocale')
->with($this->equalTo('en'));
- $event = new GetResponseEvent($this->createHttpKernel(), $this->createRequest('fr'), HttpKernelInterface::MASTER_REQUEST);
+ $event = new RequestEvent($this->createHttpKernel(), $this->createRequest('fr'), HttpKernelInterface::MASTER_REQUEST);
$this->listener->onKernelRequest($event);
}
diff --git a/vendor/symfony/http-kernel/Tests/EventListener/ValidateRequestListenerTest.php b/vendor/symfony/http-kernel/Tests/EventListener/ValidateRequestListenerTest.php
index fb7a4379bf..bbd596bc78 100644
--- a/vendor/symfony/http-kernel/Tests/EventListener/ValidateRequestListenerTest.php
+++ b/vendor/symfony/http-kernel/Tests/EventListener/ValidateRequestListenerTest.php
@@ -14,7 +14,7 @@ namespace Symfony\Component\HttpKernel\Tests\EventListener;
use PHPUnit\Framework\TestCase;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\HttpFoundation\Request;
-use Symfony\Component\HttpKernel\Event\GetResponseEvent;
+use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\EventListener\ValidateRequestListener;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\KernelEvents;
@@ -41,8 +41,8 @@ class ValidateRequestListenerTest extends TestCase
$request->headers->set('X_FORWARDED_FOR', '3.3.3.3');
$dispatcher->addListener(KernelEvents::REQUEST, [new ValidateRequestListener(), 'onKernelRequest']);
- $event = new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST);
+ $event = new RequestEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST);
- $dispatcher->dispatch(KernelEvents::REQUEST, $event);
+ $dispatcher->dispatch($event, KernelEvents::REQUEST);
}
}
diff --git a/vendor/symfony/http-kernel/Tests/Exception/AccessDeniedHttpExceptionTest.php b/vendor/symfony/http-kernel/Tests/Exception/AccessDeniedHttpExceptionTest.php
index 2bfcb2bf80..3a34cc47bc 100644
--- a/vendor/symfony/http-kernel/Tests/Exception/AccessDeniedHttpExceptionTest.php
+++ b/vendor/symfony/http-kernel/Tests/Exception/AccessDeniedHttpExceptionTest.php
@@ -6,8 +6,8 @@ use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
class AccessDeniedHttpExceptionTest extends HttpExceptionTest
{
- protected function createException()
+ protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
{
- return new AccessDeniedHttpException();
+ return new AccessDeniedHttpException($message, $previous, $code, $headers);
}
}
diff --git a/vendor/symfony/http-kernel/Tests/Exception/BadRequestHttpExceptionTest.php b/vendor/symfony/http-kernel/Tests/Exception/BadRequestHttpExceptionTest.php
index 5fd54ccf44..462fd9cb1d 100644
--- a/vendor/symfony/http-kernel/Tests/Exception/BadRequestHttpExceptionTest.php
+++ b/vendor/symfony/http-kernel/Tests/Exception/BadRequestHttpExceptionTest.php
@@ -6,8 +6,8 @@ use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
class BadRequestHttpExceptionTest extends HttpExceptionTest
{
- protected function createException()
+ protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
{
- return new BadRequestHttpException();
+ return new BadRequestHttpException($message, $previous, $code, $headers);
}
}
diff --git a/vendor/symfony/http-kernel/Tests/Exception/ConflictHttpExceptionTest.php b/vendor/symfony/http-kernel/Tests/Exception/ConflictHttpExceptionTest.php
index 63cb49e6e0..760600a10f 100644
--- a/vendor/symfony/http-kernel/Tests/Exception/ConflictHttpExceptionTest.php
+++ b/vendor/symfony/http-kernel/Tests/Exception/ConflictHttpExceptionTest.php
@@ -6,8 +6,8 @@ use Symfony\Component\HttpKernel\Exception\ConflictHttpException;
class ConflictHttpExceptionTest extends HttpExceptionTest
{
- protected function createException()
+ protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
{
- return new ConflictHttpException();
+ return new ConflictHttpException($message, $previous, $code, $headers);
}
}
diff --git a/vendor/symfony/http-kernel/Tests/Exception/GoneHttpExceptionTest.php b/vendor/symfony/http-kernel/Tests/Exception/GoneHttpExceptionTest.php
index ec5339d2af..30dafe4922 100644
--- a/vendor/symfony/http-kernel/Tests/Exception/GoneHttpExceptionTest.php
+++ b/vendor/symfony/http-kernel/Tests/Exception/GoneHttpExceptionTest.php
@@ -6,8 +6,8 @@ use Symfony\Component\HttpKernel\Exception\GoneHttpException;
class GoneHttpExceptionTest extends HttpExceptionTest
{
- protected function createException()
+ protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
{
- return new GoneHttpException();
+ return new GoneHttpException($message, $previous, $code, $headers);
}
}
diff --git a/vendor/symfony/http-kernel/Tests/Exception/HttpExceptionTest.php b/vendor/symfony/http-kernel/Tests/Exception/HttpExceptionTest.php
index f5fe97255b..a9431f4b5a 100644
--- a/vendor/symfony/http-kernel/Tests/Exception/HttpExceptionTest.php
+++ b/vendor/symfony/http-kernel/Tests/Exception/HttpExceptionTest.php
@@ -46,8 +46,16 @@ class HttpExceptionTest extends TestCase
$this->assertSame($headers, $exception->getHeaders());
}
- protected function createException()
+ public function testThrowableIsAllowedForPrevious()
{
- return new HttpException(200);
+ $previous = new class('Error of PHP 7+') extends \Error {
+ };
+ $exception = $this->createException(null, $previous);
+ $this->assertSame($previous, $exception->getPrevious());
+ }
+
+ protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
+ {
+ return new HttpException(200, $message, $previous, $headers, $code);
}
}
diff --git a/vendor/symfony/http-kernel/Tests/Exception/LengthRequiredHttpExceptionTest.php b/vendor/symfony/http-kernel/Tests/Exception/LengthRequiredHttpExceptionTest.php
index 462d3ca4fc..8676d67238 100644
--- a/vendor/symfony/http-kernel/Tests/Exception/LengthRequiredHttpExceptionTest.php
+++ b/vendor/symfony/http-kernel/Tests/Exception/LengthRequiredHttpExceptionTest.php
@@ -6,8 +6,8 @@ use Symfony\Component\HttpKernel\Exception\LengthRequiredHttpException;
class LengthRequiredHttpExceptionTest extends HttpExceptionTest
{
- protected function createException()
+ protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
{
- return new LengthRequiredHttpException();
+ return new LengthRequiredHttpException($message, $previous, $code, $headers);
}
}
diff --git a/vendor/symfony/http-kernel/Tests/Exception/MethodNotAllowedHttpExceptionTest.php b/vendor/symfony/http-kernel/Tests/Exception/MethodNotAllowedHttpExceptionTest.php
index 991f97582d..efb0b50caf 100644
--- a/vendor/symfony/http-kernel/Tests/Exception/MethodNotAllowedHttpExceptionTest.php
+++ b/vendor/symfony/http-kernel/Tests/Exception/MethodNotAllowedHttpExceptionTest.php
@@ -34,4 +34,9 @@ class MethodNotAllowedHttpExceptionTest extends HttpExceptionTest
$exception->setHeaders($headers);
$this->assertSame($headers, $exception->getHeaders());
}
+
+ protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
+ {
+ return new MethodNotAllowedHttpException(['get'], $message, $previous, $code, $headers);
+ }
}
diff --git a/vendor/symfony/http-kernel/Tests/Exception/NotAcceptableHttpExceptionTest.php b/vendor/symfony/http-kernel/Tests/Exception/NotAcceptableHttpExceptionTest.php
index 4c0db7a3cb..021c69e289 100644
--- a/vendor/symfony/http-kernel/Tests/Exception/NotAcceptableHttpExceptionTest.php
+++ b/vendor/symfony/http-kernel/Tests/Exception/NotAcceptableHttpExceptionTest.php
@@ -6,8 +6,8 @@ use Symfony\Component\HttpKernel\Exception\NotAcceptableHttpException;
class NotAcceptableHttpExceptionTest extends HttpExceptionTest
{
- protected function createException()
+ protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
{
- return new NotAcceptableHttpException();
+ return new NotAcceptableHttpException($message, $previous, $code, $headers);
}
}
diff --git a/vendor/symfony/http-kernel/Tests/Exception/NotFoundHttpExceptionTest.php b/vendor/symfony/http-kernel/Tests/Exception/NotFoundHttpExceptionTest.php
index 62ede5b4b8..0bf369b1a0 100644
--- a/vendor/symfony/http-kernel/Tests/Exception/NotFoundHttpExceptionTest.php
+++ b/vendor/symfony/http-kernel/Tests/Exception/NotFoundHttpExceptionTest.php
@@ -6,8 +6,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class NotFoundHttpExceptionTest extends HttpExceptionTest
{
- protected function createException()
+ protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
{
- return new NotFoundHttpException();
+ return new NotFoundHttpException($message, $previous, $code, $headers);
}
}
diff --git a/vendor/symfony/http-kernel/Tests/Exception/PreconditionFailedHttpExceptionTest.php b/vendor/symfony/http-kernel/Tests/Exception/PreconditionFailedHttpExceptionTest.php
index 809252b757..04d79c499d 100644
--- a/vendor/symfony/http-kernel/Tests/Exception/PreconditionFailedHttpExceptionTest.php
+++ b/vendor/symfony/http-kernel/Tests/Exception/PreconditionFailedHttpExceptionTest.php
@@ -6,8 +6,8 @@ use Symfony\Component\HttpKernel\Exception\PreconditionFailedHttpException;
class PreconditionFailedHttpExceptionTest extends HttpExceptionTest
{
- protected function createException()
+ protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
{
- return new PreconditionFailedHttpException();
+ return new PreconditionFailedHttpException($message, $previous, $code, $headers);
}
}
diff --git a/vendor/symfony/http-kernel/Tests/Exception/PreconditionRequiredHttpExceptionTest.php b/vendor/symfony/http-kernel/Tests/Exception/PreconditionRequiredHttpExceptionTest.php
index 69d362e3f6..82076617a8 100644
--- a/vendor/symfony/http-kernel/Tests/Exception/PreconditionRequiredHttpExceptionTest.php
+++ b/vendor/symfony/http-kernel/Tests/Exception/PreconditionRequiredHttpExceptionTest.php
@@ -6,8 +6,8 @@ use Symfony\Component\HttpKernel\Exception\PreconditionRequiredHttpException;
class PreconditionRequiredHttpExceptionTest extends HttpExceptionTest
{
- protected function createException()
+ protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
{
- return new PreconditionRequiredHttpException();
+ return new PreconditionRequiredHttpException($message, $previous, $code, $headers);
}
}
diff --git a/vendor/symfony/http-kernel/Tests/Exception/ServiceUnavailableHttpExceptionTest.php b/vendor/symfony/http-kernel/Tests/Exception/ServiceUnavailableHttpExceptionTest.php
index daa4fa407a..fac197c852 100644
--- a/vendor/symfony/http-kernel/Tests/Exception/ServiceUnavailableHttpExceptionTest.php
+++ b/vendor/symfony/http-kernel/Tests/Exception/ServiceUnavailableHttpExceptionTest.php
@@ -35,8 +35,8 @@ class ServiceUnavailableHttpExceptionTest extends HttpExceptionTest
$this->assertSame($headers, $exception->getHeaders());
}
- protected function createException()
+ protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
{
- return new ServiceUnavailableHttpException();
+ return new ServiceUnavailableHttpException(null, $message, $previous, $code, $headers);
}
}
diff --git a/vendor/symfony/http-kernel/Tests/Exception/TooManyRequestsHttpExceptionTest.php b/vendor/symfony/http-kernel/Tests/Exception/TooManyRequestsHttpExceptionTest.php
index 0048ec85c0..8b59e9894a 100644
--- a/vendor/symfony/http-kernel/Tests/Exception/TooManyRequestsHttpExceptionTest.php
+++ b/vendor/symfony/http-kernel/Tests/Exception/TooManyRequestsHttpExceptionTest.php
@@ -35,8 +35,8 @@ class TooManyRequestsHttpExceptionTest extends HttpExceptionTest
$this->assertSame($headers, $exception->getHeaders());
}
- protected function createException()
+ protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
{
- return new TooManyRequestsHttpException();
+ return new TooManyRequestsHttpException(null, $message, $previous, $code, $headers);
}
}
diff --git a/vendor/symfony/http-kernel/Tests/Exception/UnauthorizedHttpExceptionTest.php b/vendor/symfony/http-kernel/Tests/Exception/UnauthorizedHttpExceptionTest.php
index c7239e70b3..92d427b6e4 100644
--- a/vendor/symfony/http-kernel/Tests/Exception/UnauthorizedHttpExceptionTest.php
+++ b/vendor/symfony/http-kernel/Tests/Exception/UnauthorizedHttpExceptionTest.php
@@ -34,4 +34,9 @@ class UnauthorizedHttpExceptionTest extends HttpExceptionTest
$exception->setHeaders($headers);
$this->assertSame($headers, $exception->getHeaders());
}
+
+ protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
+ {
+ return new UnauthorizedHttpException('Challenge', $message, $previous, $code, $headers);
+ }
}
diff --git a/vendor/symfony/http-kernel/Tests/Exception/UnprocessableEntityHttpExceptionTest.php b/vendor/symfony/http-kernel/Tests/Exception/UnprocessableEntityHttpExceptionTest.php
index 05d8d787aa..ffa4e177ee 100644
--- a/vendor/symfony/http-kernel/Tests/Exception/UnprocessableEntityHttpExceptionTest.php
+++ b/vendor/symfony/http-kernel/Tests/Exception/UnprocessableEntityHttpExceptionTest.php
@@ -6,8 +6,8 @@ use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
class UnprocessableEntityHttpExceptionTest extends HttpExceptionTest
{
- protected function createException()
+ protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
{
- return new UnprocessableEntityHttpException();
+ return new UnprocessableEntityHttpException($message, $previous, $code, $headers);
}
}
diff --git a/vendor/symfony/http-kernel/Tests/Exception/UnsupportedMediaTypeHttpExceptionTest.php b/vendor/symfony/http-kernel/Tests/Exception/UnsupportedMediaTypeHttpExceptionTest.php
index 4dae039c11..fa28bbd19b 100644
--- a/vendor/symfony/http-kernel/Tests/Exception/UnsupportedMediaTypeHttpExceptionTest.php
+++ b/vendor/symfony/http-kernel/Tests/Exception/UnsupportedMediaTypeHttpExceptionTest.php
@@ -6,8 +6,8 @@ use Symfony\Component\HttpKernel\Exception\UnsupportedMediaTypeHttpException;
class UnsupportedMediaTypeHttpExceptionTest extends HttpExceptionTest
{
- protected function createException()
+ protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
{
- return new UnsupportedMediaTypeHttpException();
+ return new UnsupportedMediaTypeHttpException($message, $previous, $code, $headers);
}
}
diff --git a/vendor/symfony/http-kernel/Tests/Fixtures/TestClient.php b/vendor/symfony/http-kernel/Tests/Fixtures/TestClient.php
index e7d60cff3d..140cbfbf51 100644
--- a/vendor/symfony/http-kernel/Tests/Fixtures/TestClient.php
+++ b/vendor/symfony/http-kernel/Tests/Fixtures/TestClient.php
@@ -11,9 +11,9 @@
namespace Symfony\Component\HttpKernel\Tests\Fixtures;
-use Symfony\Component\HttpKernel\Client;
+use Symfony\Component\HttpKernel\HttpKernelBrowser;
-class TestClient extends Client
+class TestClient extends HttpKernelBrowser
{
protected function getScript($request)
{
diff --git a/vendor/symfony/http-kernel/Tests/Fragment/HIncludeFragmentRendererTest.php b/vendor/symfony/http-kernel/Tests/Fragment/HIncludeFragmentRendererTest.php
index 6125d95ff4..f80f5f811a 100644
--- a/vendor/symfony/http-kernel/Tests/Fragment/HIncludeFragmentRendererTest.php
+++ b/vendor/symfony/http-kernel/Tests/Fragment/HIncludeFragmentRendererTest.php
@@ -16,6 +16,8 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Controller\ControllerReference;
use Symfony\Component\HttpKernel\Fragment\HIncludeFragmentRenderer;
use Symfony\Component\HttpKernel\UriSigner;
+use Twig\Environment;
+use Twig\Loader\ArrayLoader;
class HIncludeFragmentRendererTest extends TestCase
{
@@ -74,29 +76,26 @@ class HIncludeFragmentRendererTest extends TestCase
$this->assertEquals('<hx:include src="/foo" p1="v1" p2="v2" id="bar">default</hx:include>', $strategy->render('/foo', Request::create('/'), ['default' => 'default', 'id' => 'bar', 'attributes' => ['p1' => 'v1', 'p2' => 'v2']])->getContent());
}
- public function testRenderWithDefaultText()
+ public function testRenderWithTwigAndDefaultText()
{
- $engine = $this->getMockBuilder('Symfony\\Component\\Templating\\EngineInterface')->getMock();
- $engine->expects($this->once())
- ->method('exists')
- ->with('default')
- ->willThrowException(new \InvalidArgumentException());
-
- // only default
- $strategy = new HIncludeFragmentRenderer($engine);
- $this->assertEquals('<hx:include src="/foo">default</hx:include>', $strategy->render('/foo', Request::create('/'), ['default' => 'default'])->getContent());
+ $twig = new Environment($loader = new ArrayLoader());
+ $strategy = new HIncludeFragmentRenderer($twig);
+ $this->assertEquals('<hx:include src="/foo">loading...</hx:include>', $strategy->render('/foo', Request::create('/'), ['default' => 'loading...'])->getContent());
}
- public function testRenderWithEngineAndDefaultText()
+ /**
+ * @group legacy
+ */
+ public function testRenderWithDefaultTextLegacy()
{
$engine = $this->getMockBuilder('Symfony\\Component\\Templating\\EngineInterface')->getMock();
$engine->expects($this->once())
->method('exists')
- ->with('loading...')
- ->willThrowException(new \RuntimeException());
+ ->with('default')
+ ->willThrowException(new \InvalidArgumentException());
// only default
$strategy = new HIncludeFragmentRenderer($engine);
- $this->assertEquals('<hx:include src="/foo">loading...</hx:include>', $strategy->render('/foo', Request::create('/'), ['default' => 'loading...'])->getContent());
+ $this->assertEquals('<hx:include src="/foo">default</hx:include>', $strategy->render('/foo', Request::create('/'), ['default' => 'default'])->getContent());
}
}
diff --git a/vendor/symfony/http-kernel/Tests/Fragment/InlineFragmentRendererTest.php b/vendor/symfony/http-kernel/Tests/Fragment/InlineFragmentRendererTest.php
index 155493d7f4..d6f0ff7771 100644
--- a/vendor/symfony/http-kernel/Tests/Fragment/InlineFragmentRendererTest.php
+++ b/vendor/symfony/http-kernel/Tests/Fragment/InlineFragmentRendererTest.php
@@ -17,9 +17,11 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Controller\ControllerReference;
+use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\Fragment\InlineFragmentRenderer;
use Symfony\Component\HttpKernel\HttpKernel;
use Symfony\Component\HttpKernel\KernelEvents;
+use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
class InlineFragmentRendererTest extends TestCase
{
@@ -72,7 +74,7 @@ class InlineFragmentRendererTest extends TestCase
*/
public function testRenderExceptionNoIgnoreErrors()
{
- $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
+ $dispatcher = $this->getMockBuilder(EventDispatcherInterface::class)->getMock();
$dispatcher->expects($this->never())->method('dispatch');
$strategy = new InlineFragmentRenderer($this->getKernel($this->throwException(new \RuntimeException('foo'))), $dispatcher);
@@ -82,12 +84,16 @@ class InlineFragmentRendererTest extends TestCase
public function testRenderExceptionIgnoreErrors()
{
- $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
- $dispatcher->expects($this->once())->method('dispatch')->with(KernelEvents::EXCEPTION);
+ $exception = new \RuntimeException('foo');
+ $kernel = $this->getKernel($this->throwException($exception));
+ $request = Request::create('/');
+ $expectedEvent = new ExceptionEvent($kernel, $request, $kernel::SUB_REQUEST, $exception);
+ $dispatcher = $this->getMockBuilder(EventDispatcherInterface::class)->getMock();
+ $dispatcher->expects($this->once())->method('dispatch')->with($expectedEvent, KernelEvents::EXCEPTION);
- $strategy = new InlineFragmentRenderer($this->getKernel($this->throwException(new \RuntimeException('foo'))), $dispatcher);
+ $strategy = new InlineFragmentRenderer($kernel, $dispatcher);
- $this->assertEmpty($strategy->render('/', Request::create('/'), ['ignore_errors' => true])->getContent());
+ $this->assertEmpty($strategy->render('/', $request, ['ignore_errors' => true])->getContent());
}
public function testRenderExceptionIgnoreErrorsWithAlt()
diff --git a/vendor/symfony/http-kernel/Tests/HttpCache/HttpCacheTest.php b/vendor/symfony/http-kernel/Tests/HttpCache/HttpCacheTest.php
index 7b3cac78c7..309e8aaaec 100644
--- a/vendor/symfony/http-kernel/Tests/HttpCache/HttpCacheTest.php
+++ b/vendor/symfony/http-kernel/Tests/HttpCache/HttpCacheTest.php
@@ -1508,6 +1508,44 @@ class HttpCacheTest extends HttpCacheTestCase
// Surrogate request
$cache->handle($request, HttpKernelInterface::SUB_REQUEST);
}
+
+ public function testTraceHeaderNameCanBeChanged()
+ {
+ $this->cacheConfig['trace_header'] = 'X-My-Header';
+ $this->setNextResponse();
+ $this->request('GET', '/');
+
+ $this->assertTrue($this->response->headers->has('X-My-Header'));
+ }
+
+ public function testTraceLevelDefaultsToFullIfDebug()
+ {
+ $this->setNextResponse();
+ $this->request('GET', '/');
+
+ $this->assertTrue($this->response->headers->has('X-Symfony-Cache'));
+ $this->assertEquals('GET /: miss', $this->response->headers->get('X-Symfony-Cache'));
+ }
+
+ public function testTraceLevelDefaultsToNoneIfNotDebug()
+ {
+ $this->cacheConfig['debug'] = false;
+ $this->setNextResponse();
+ $this->request('GET', '/');
+
+ $this->assertFalse($this->response->headers->has('X-Symfony-Cache'));
+ }
+
+ public function testTraceLevelShort()
+ {
+ $this->cacheConfig['trace_level'] = 'short';
+
+ $this->setNextResponse();
+ $this->request('GET', '/');
+
+ $this->assertTrue($this->response->headers->has('X-Symfony-Cache'));
+ $this->assertEquals('miss', $this->response->headers->get('X-Symfony-Cache'));
+ }
}
class TestKernel implements HttpKernelInterface
diff --git a/vendor/symfony/http-kernel/Tests/HttpCache/HttpCacheTestCase.php b/vendor/symfony/http-kernel/Tests/HttpCache/HttpCacheTestCase.php
index 1eb4617447..fde389c28f 100644
--- a/vendor/symfony/http-kernel/Tests/HttpCache/HttpCacheTestCase.php
+++ b/vendor/symfony/http-kernel/Tests/HttpCache/HttpCacheTestCase.php
@@ -122,7 +122,9 @@ class HttpCacheTestCase extends TestCase
$this->store = new Store(sys_get_temp_dir().'/http_cache');
- $this->cacheConfig['debug'] = true;
+ if (!isset($this->cacheConfig['debug'])) {
+ $this->cacheConfig['debug'] = true;
+ }
$this->esi = $esi ? new Esi() : null;
$this->cache = new HttpCache($this->kernel, $this->store, $this->esi, $this->cacheConfig);
diff --git a/vendor/symfony/http-kernel/Tests/ClientTest.php b/vendor/symfony/http-kernel/Tests/HttpKernelBrowserTest.php
index c260727849..4447e951f6 100644
--- a/vendor/symfony/http-kernel/Tests/ClientTest.php
+++ b/vendor/symfony/http-kernel/Tests/HttpKernelBrowserTest.php
@@ -16,17 +16,17 @@ use Symfony\Component\HttpFoundation\Cookie;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\StreamedResponse;
-use Symfony\Component\HttpKernel\Client;
+use Symfony\Component\HttpKernel\HttpKernelBrowser;
use Symfony\Component\HttpKernel\Tests\Fixtures\TestClient;
/**
* @group time-sensitive
*/
-class ClientTest extends TestCase
+class HttpKernelBrowserTest extends TestCase
{
public function testDoRequest()
{
- $client = new Client(new TestHttpKernel());
+ $client = new HttpKernelBrowser(new TestHttpKernel());
$client->request('GET', '/');
$this->assertEquals('Request: /', $client->getResponse()->getContent(), '->doRequest() uses the request handler to make the request');
@@ -54,7 +54,7 @@ class ClientTest extends TestCase
public function testFilterResponseConvertsCookies()
{
- $client = new Client(new TestHttpKernel());
+ $client = new HttpKernelBrowser(new TestHttpKernel());
$r = new \ReflectionObject($client);
$m = $r->getMethod('filterResponse');
@@ -75,7 +75,7 @@ class ClientTest extends TestCase
public function testFilterResponseSupportsStreamedResponses()
{
- $client = new Client(new TestHttpKernel());
+ $client = new HttpKernelBrowser(new TestHttpKernel());
$r = new \ReflectionObject($client);
$m = $r->getMethod('filterResponse');
@@ -97,7 +97,7 @@ class ClientTest extends TestCase
@unlink($target);
$kernel = new TestHttpKernel();
- $client = new Client($kernel);
+ $client = new HttpKernelBrowser($kernel);
$files = [
['tmp_name' => $source, 'name' => 'original', 'type' => 'mime/original', 'size' => null, 'error' => UPLOAD_ERR_OK],
@@ -128,7 +128,7 @@ class ClientTest extends TestCase
public function testUploadedFileWhenNoFileSelected()
{
$kernel = new TestHttpKernel();
- $client = new Client($kernel);
+ $client = new HttpKernelBrowser($kernel);
$file = ['tmp_name' => '', 'name' => '', 'type' => '', 'size' => 0, 'error' => UPLOAD_ERR_NO_FILE];
@@ -145,7 +145,7 @@ class ClientTest extends TestCase
$source = tempnam(sys_get_temp_dir(), 'source');
$kernel = new TestHttpKernel();
- $client = new Client($kernel);
+ $client = new HttpKernelBrowser($kernel);
$file = $this
->getMockBuilder('Symfony\Component\HttpFoundation\File\UploadedFile')
diff --git a/vendor/symfony/http-kernel/Tests/HttpKernelTest.php b/vendor/symfony/http-kernel/Tests/HttpKernelTest.php
index 4d1e267e3a..d1162f0431 100644
--- a/vendor/symfony/http-kernel/Tests/HttpKernelTest.php
+++ b/vendor/symfony/http-kernel/Tests/HttpKernelTest.php
@@ -20,8 +20,6 @@ use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface;
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
-use Symfony\Component\HttpKernel\Event\FilterControllerArgumentsEvent;
-use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\HttpKernel\Exception\ControllerDoesNotReturnResponseException;
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
@@ -128,7 +126,7 @@ class HttpKernelTest extends TestCase
public function testHandleWhenAnExceptionIsHandledWithASpecificStatusCode($expectedStatusCode)
{
$dispatcher = new EventDispatcher();
- $dispatcher->addListener(KernelEvents::EXCEPTION, function (GetResponseForExceptionEvent $event) use ($expectedStatusCode) {
+ $dispatcher->addListener(KernelEvents::EXCEPTION, function ($event) use ($expectedStatusCode) {
$event->allowCustomResponseCode();
$event->setResponse(new Response('', $expectedStatusCode));
});
@@ -215,20 +213,19 @@ class HttpKernelTest extends TestCase
public function testHandleWhenTheControllerDoesNotReturnAResponse()
{
$dispatcher = new EventDispatcher();
- $kernel = $this->getHttpKernel($dispatcher, function () { return 'foo'; });
+ $kernel = $this->getHttpKernel($dispatcher, function () {});
try {
$kernel->handle(new Request());
$this->fail('The kernel should throw an exception.');
} catch (ControllerDoesNotReturnResponseException $e) {
- }
+ $first = $e->getTrace()[0];
- $first = $e->getTrace()[0];
-
- // `file` index the array starting at 0, and __FILE__ starts at 1
- $line = file($first['file'])[$first['line'] - 2];
- $this->assertContains('// call controller', $line);
+ // `file` index the array starting at 0, and __FILE__ starts at 1
+ $line = file($first['file'])[$first['line'] - 2];
+ $this->assertContains('// call controller', $line);
+ }
}
public function testHandleWhenTheControllerDoesNotReturnAResponseButAViewIsRegistered()
@@ -257,7 +254,7 @@ class HttpKernelTest extends TestCase
public function testHandleAllowChangingControllerArguments()
{
$dispatcher = new EventDispatcher();
- $dispatcher->addListener(KernelEvents::CONTROLLER_ARGUMENTS, function (FilterControllerArgumentsEvent $event) {
+ $dispatcher->addListener(KernelEvents::CONTROLLER_ARGUMENTS, function ($event) {
$event->setArguments(['foo']);
});
@@ -269,7 +266,7 @@ class HttpKernelTest extends TestCase
public function testHandleAllowChangingControllerAndArguments()
{
$dispatcher = new EventDispatcher();
- $dispatcher->addListener(KernelEvents::CONTROLLER_ARGUMENTS, function (FilterControllerArgumentsEvent $event) {
+ $dispatcher->addListener(KernelEvents::CONTROLLER_ARGUMENTS, function ($event) {
$oldController = $event->getController();
$oldArguments = $event->getArguments();
diff --git a/vendor/symfony/http-kernel/Tests/KernelTest.php b/vendor/symfony/http-kernel/Tests/KernelTest.php
index 57bd704c92..5be4fc8d83 100644
--- a/vendor/symfony/http-kernel/Tests/KernelTest.php
+++ b/vendor/symfony/http-kernel/Tests/KernelTest.php
@@ -64,6 +64,20 @@ class KernelTest extends TestCase
$this->assertNull($clone->getContainer());
}
+ /**
+ * @expectedException \InvalidArgumentException
+ * @expectedExceptionMessage The environment "test.env" contains invalid characters, it can only contain characters allowed in PHP class names.
+ */
+ public function testClassNameValidityGetter()
+ {
+ // We check the classname that will be generated by using a $env that
+ // contains invalid characters.
+ $env = 'test.env';
+ $kernel = new KernelForTest($env, false);
+
+ $kernel->boot();
+ }
+
public function testInitializeContainerClearsOldContainers()
{
$fs = new Filesystem();
@@ -330,9 +344,8 @@ EOF;
$env = 'test_env';
$debug = true;
$kernel = new KernelForTest($env, $debug);
-
- $expected = serialize([$env, $debug]);
- $this->assertEquals($expected, $kernel->serialize());
+ $expected = "O:57:\"Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest\":2:{s:14:\"\0*\0environment\";s:8:\"test_env\";s:8:\"\0*\0debug\";b:1;}";
+ $this->assertEquals($expected, serialize($kernel));
}
/**
diff --git a/vendor/symfony/http-kernel/Tests/Log/LoggerTest.php b/vendor/symfony/http-kernel/Tests/Log/LoggerTest.php
index 7354000b16..17865203f2 100644
--- a/vendor/symfony/http-kernel/Tests/Log/LoggerTest.php
+++ b/vendor/symfony/http-kernel/Tests/Log/LoggerTest.php
@@ -34,7 +34,7 @@ class LoggerTest extends TestCase
protected function setUp()
{
- $this->tmpFile = sys_get_temp_dir().\DIRECTORY_SEPARATOR.'log';
+ $this->tmpFile = tempnam(sys_get_temp_dir(), 'log');
$this->logger = new Logger(LogLevel::DEBUG, $this->tmpFile);
}