10000 Merge branch '5.2' into 5.3 · symfony/symfony@888cf5c · GitHub
[go: up one dir, main page]

Skip to content

Commit 888cf5c

Browse files
committed
Merge branch '5.2' into 5.3
* 5.2: do not mock the Request class do not mock event classes Fix use_notify default value for PostgreSqlConnection recover from failed deserializations [ErrorHandle] Remove a link from the exception page [Validator] Added Ukrainian translations [GHA] Clarify some bits in the deps=high script
2 parents 4a03392 + 3e148e8 commit 888cf5c

File tree

17 files changed

+96
-267
lines changed

17 files changed

+96
-267
lines changed

.github/workflows/unit-tests.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,24 +184,26 @@ jobs:
184184
# matrix.mode = high-deps
185185
echo "$COMPONENTS" | xargs -n1 | parallel -j +3 "_run_tests {} 'cd {} && $COMPOSER_UP && $PHPUNIT$LEGACY'" || X=1
186186
187+
# get a list of the patched components (relies on .github/build-packages.php being called in the previous step)
187188
(cd src/Symfony/Component/HttpFoundation; mv composer.bak composer.json)
188-
COMPONENTS=$(git diff --name-only src/ | grep composer.json || true)
189+
PATCHED_COMPONENTS=$(git diff --name-only src/ | grep composer.json || true)
189190
190-
if [[ $COMPONENTS && $SYMFONY_VERSION = *.4 ]]; then
191+
# for x.4 branches, checkout and test previous major with the patched components (only for patched components)
192+
if [[ $PATCHED_COMPONENTS && $SYMFONY_VERSION = *.4 ]]; then
191193
export FLIP='^'
192194
SYMFONY_VERSION=$(echo $SYMFONY_VERSION | awk '{print $1 - 1}')
193195
echo -e "\\n\\e[33;1mChecking out Symfony $SYMFONY_VERSION and running tests with patched components as deps\\e[0m"
194196
export COMPOSER_ROOT_VERSION=$SYMFONY_VERSION.x-dev
195197
export SYMFONY_REQUIRE=">=$SYMFONY_VERSION"
196198
git fetch --depth=2 origin $SYMFONY_VERSION
197199
git checkout -m FETCH_HEAD
198-
COMPONENTS=$(echo "$COMPONENTS" | xargs dirname | xargs -n1 -I{} bash -c "[ -e '{}/phpunit.xml.dist' ] && echo '{}'" | sort || true)
200+
PATCHED_COMPONENTS=$(echo "$PATCHED_COMPONENTS" | xargs dirname | xargs -n1 -I{} bash -c "[ -e '{}/phpunit.xml.dist' ] && echo '{}'" | sort || true)
199201
(cd src/Symfony/Component/HttpFoundation; composer require --dev --no-update mongodb/mongodb)
200-
if [[ $COMPONENTS ]]; then
202+
if [[ $PATCHED_COMPONENTS ]]; then
201203
echo "::group::install phpunit"
202204
./phpunit install
203205
echo "::endgroup::"
204-
echo "$COMPONENTS" | parallel -j +3 "_run_tests {} 'cd {} && rm composer.lock vendor/ -Rf && $COMPOSER_UP && $PHPUNIT$LEGACY'" || X=1
206+
echo "$PATCHED_COMPONENTS" | parallel -j +3 "_run_tests {} 'cd {} && rm composer.lock vendor/ -Rf && $COMPOSER_UP && $PHPUNIT$LEGACY'" || X=1
205207
fi
206208
fi
207209

src/Symfony/Bridge/Monolog/Tests/Processor/ConsoleCommandProcessorTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\Console\Command\Command;
1717
use Symfony\Component\Console\Event\ConsoleEvent;
1818
use Symfony\Component\Console\Input\InputInterface;
19+
use Symfony\Component\Console\Output\OutputInterface;
1920

2021
class ConsoleCommandProcessorTest extends TestCase
2122
{
@@ -66,10 +67,7 @@ private function getConsoleEvent(): ConsoleEvent
6667
$input->method('getOptions')->willReturn(self::TEST_OPTIONS);
6768
$command = $this->createMock(Command::class);
6869
$command->method('getName')->willReturn(self::TEST_NAME);
69-
$consoleEvent = $this->createMock(ConsoleEvent::class);
70-
$consoleEvent->method('getCommand')->willReturn($command);
71-
$consoleEvent->method('getInput')->willReturn($input);
7270

73-
return $consoleEvent;
71+
return new ConsoleEvent($command, $input, $this->createMock(OutputInterface::class));
7472
}
7573
}

src/Symfony/Bundle/WebProfilerBundle/Tests/EventListener/WebDebugToolbarListenerTest.php

Lines changed: 23 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Bundle\WebProfilerBundle\Csp\ContentSecurityPolicyHandler;
1616
use Symfony\Bundle\WebProfilerBundle\EventListener\WebDebugToolbarListener;
17-
use Symfony\Component\HttpFoundation\HeaderBag;
1817
use Symfony\Component\HttpFoundation\Request;
1918
use Symfony\Component\HttpFoundation\Response;
2019
use Symfony\Component\HttpFoundation\Session\Session;
@@ -63,11 +62,11 @@ public function getInjectToolbarTests()
6362
/**
6463
* @dataProvider provideRedirects
6564
*/
66-
public function testHtmlRedirectionIsIntercepted($statusCode, $hasSession)
65+
public function testHtmlRedirectionIsIntercepted($statusCode)
6766
{
6867
$response = new Response('Some content', $statusCode);
6968
$response->headers->set('X-Debug-Token', 'xxxxxxxx');
70-
$event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(false, 'html', $hasSession), HttpKernelInterface::MAIN_REQUEST, $response);
69+
$event = new ResponseEvent($this->createMock(Kernel::class), new Request(), HttpKernelInterface::MAIN_REQUEST, $response);
7170

7271
$listener = new WebDebugToolbarListener($this->getTwigMock('Redirection'), true);
7372
$listener->onKernelResponse($event);
@@ -80,7 +79,7 @@ public function testNonHtmlRedirectionIsNotIntercepted()
8079
{
8180
$response = new Response('Some content', '301');
8281
$response->headers->set('X-Debug-Token', 'xxxxxxxx');
83-
$event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(false, 'json', true), HttpKernelInterface::MAIN_REQUEST, $response);
82+
$event = new ResponseEvent($this->createMock(Kernel::class), new Request([], [], ['_format' => 'json']), HttpKernelInterface::MAIN_REQUEST, $response);
8483

8584
$listener = new WebDebugToolbarListener($this->getTwigMock('Redirection'), true);
8685
$listener->onKernelResponse($event);
@@ -94,7 +93,7 @@ public function testToolbarIsInjected()
9493
$response = new Response('<html><head></head><body></body></html>');
9594
$response->headers->set('X-Debug-Token', 'xxxxxxxx');
9695

97-
$event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MAIN_REQUEST, $response);
96+
$event = new ResponseEvent($this->createMock(Kernel::class), new Request(), HttpKernelInterface::MAIN_REQUEST, $response);
9897

9998
$listener = new WebDebugToolbarListener($this->getTwigMock());
10099
$listener->onKernelResponse($event);
@@ -110,7 +109,7 @@ public function testToolbarIsNotInjectedOnNonHtmlContentType()
110109
$response = new Response('<html><head></head><body></body></html>');
111110
$response->headers->set('X-Debug-Token', 'xxxxxxxx');
112111
$response->headers->set('Content-Type', 'text/xml');
113-
$event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MAIN_REQUEST, $response);
112+
$event = new ResponseEvent($this->createMock(Kernel::class), new Request(), HttpKernelInterface::MAIN_REQUEST, $response);
114113

115114
$listener = new WebDebugToolbarListener($this->getTwigMock());
116115
$listener->onKernelResponse($event);
@@ -126,7 +125,7 @@ public function testToolbarIsNotInjectedOnContentDispositionAttachment()
126125
$response = new Response('<html><head></head><body></body></html>');
127126
$response->headers->set('X-Debug-Token', 'xxxxxxxx');
128127
$response->headers->set('Content-Disposition', 'attachment; filename=test.html');
129-
$event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(false, 'html'), HttpKernelInterface::MAIN_REQUEST, $response);
128+
$event = new ResponseEvent($this->createMock(Kernel::class), new Request(), HttpKernelInterface::MAIN_REQUEST, $response);
130129

131130
$listener = new WebDebugToolbarListener($this->getTwigMock());
132131
$listener->onKernelResponse($event);
@@ -138,11 +137,11 @@ public function testToolbarIsNotInjectedOnContentDispositionAttachment()
138137
* @depends testToolbarIsInjected
139138
* @dataProvider provideRedirects
140139
*/
141-
public function testToolbarIsNotInjectedOnRedirection($statusCode, $hasSession)
140+
public function testToolbarIsNotInjectedOnRedirection($statusCode)
142141
{
143142
$response = new Response('<html><head></head><body></body></html>', $statusCode);
144143
$response->headers->set('X-Debug-Token', 'xxxxxxxx');
145-
$event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(false, 'html', $hasSession), HttpKernelInterface::MAIN_REQUEST, $response);
144+
$event = new ResponseEvent($this->createMock(Kernel::class), new Request(), HttpKernelInterface::MAIN_REQUEST, $response);
146145

147146
$listener = new WebDebugToolbarListener($this->getTwigMock());
148147
$listener->onKernelResponse($event);
@@ -153,10 +152,8 @@ public function testToolbarIsNotInjectedOnRedirection($statusCode, $hasSession)
153152
public function provideRedirects()
154153
{
155154
return [
156-
[301, true],
157-
[302, true],
158-
[301, false],
159-
[302, false],
155+
[301],
156+
[302],
160157
];
161158
}
162159

@@ -167,7 +164,7 @@ public function testToolbarIsNotInjectedWhenThereIsNoNoXDebugTokenResponseHeader
167164
{
168165
$response = new Response('<html><head></head><body></body></html>');
169166

170-
$event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MAIN_REQUEST, $response);
167+
$event = new ResponseEvent($this->createMock(Kernel::class), new Request(), HttpKernelInterface::MAIN_REQUEST, $response);
171168

172169
$listener = new WebDebugToolbarListener($this->getTwigMock());
173170
$listener->onKernelResponse($event);
@@ -183,7 +180,7 @@ public function testToolbarIsNotInjectedWhenOnSubRequest()
183180
$response = new Response('<html><head></head><body></body></html>');
184181
$response->headers->set('X-Debug-Token', 'xxxxxxxx');
185182

186-
$event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::SUB_REQUEST, $response);
183+
$event = new ResponseEvent($this->createMock(Kernel::class), new Request(), HttpKernelInterface::SUB_REQUEST, $response);
187184

188185
$listener = new WebDebugToolbarListener($this->getTwigMock());
189186
$listener->onKernelResponse($event);
@@ -199,7 +196,7 @@ public function testToolbarIsNotInjectedOnIncompleteHtmlResponses()
199196
$response = new Response('<div>Some content</div>');
200197
$response->headers->set('X-Debug-Token', 'xxxxxxxx');
201198

202-
$event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MAIN_REQUEST, $response);
199+
$event = new ResponseEvent($this->createMock(Kernel::class), new Request(), HttpKernelInterface::MAIN_REQUEST, $response);
203200

204201
$listener = new WebDebugToolbarListener($this->getTwigMock());
205202
$listener->onKernelResponse($event);
@@ -215,7 +212,10 @@ public function testToolbarIsNotInjectedOnXmlHttpRequests()
215212
$response = new Response('<html><head></head><body></body></html>');
216213
$response->headers->set('X-Debug-Token', 'xxxxxxxx');
217214

218-
$event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(true), HttpKernelInterface::MAIN_REQUEST, $response);
215+
$request = new Request();
216+
$request->headers->set('X-Requested-With', 'XMLHttpRequest');
217+
218+
$event = new ResponseEvent($this->createMock(Kernel::class), $request, HttpKernelInterface::MAIN_REQUEST, $response);
219219

220220
$listener = new WebDebugToolbarListener($this->getTwigMock());
221221
$listener->onKernelResponse($event);
@@ -231,7 +231,7 @@ public function testToolbarIsNotInjectedOnNonHtmlRequests()
231231
$response = new Response('<html><head></head><body></body></html>');
232232
$response->headers->set('X-Debug-Token', 'xxxxxxxx');
233233

234-
$event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(false, 'json'), HttpKernelInterface::MAIN_REQUEST, $response);
234+
$event = new ResponseEvent($this->createMock(Kernel::class), new Request([], [], ['_format' => 'json']), HttpKernelInterface::MAIN_REQUEST, $response);
235235

236236
$listener = new WebDebugToolbarListener($this->getTwigMock());
237237
$listener->onKernelResponse($event);
@@ -252,7 +252,7 @@ public function testXDebugUrlHeader()
252252
->willReturn('http://mydomain.com/_profiler/xxxxxxxx')
253253
;
254254

255-
$event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MAIN_REQUEST, $response);
255+
$event = new ResponseEvent($this->createMock(Kernel::class), new Request(), HttpKernelInterface::MAIN_REQUEST, $response);
256256

257257
$listener = new WebDebugToolbarListener($this->getTwigMock(), false, WebDebugToolbarListener::ENABLED, $urlGenerator);
258258
$listener->onKernelResponse($event);
@@ -273,7 +273,7 @@ public function testThrowingUrlGenerator()
273273
->willThrowException(new \Exception('foo'))
274274
;
275275

276-
$event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MAIN_REQUEST, $response);
276+
$event = new ResponseEvent($this->createMock(Kernel::class), new Request(), HttpKernelInterface::MAIN_REQUEST, $response);
277277

278278
$listener = new WebDebugToolbarListener($this->getTwigMock(), false, WebDebugToolbarListener::ENABLED, $urlGenerator);
279279
$listener->onKernelResponse($event);
@@ -294,7 +294,7 @@ public function testThrowingErrorCleanup()
294294
->willThrowException(new \Exception("This\nmultiline\r\ntabbed text should\tcome out\r on\n \ta single plain\r\nline"))
295295
;
296296

297-
$event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MAIN_REQUEST, $response);
297+
$event = new ResponseEvent($this->createMock(Kernel::class), new Request(), HttpKernelInterface::MAIN_REQUEST, $response);
298298

299299
$listener = new WebDebugToolbarListener($this->getTwigMock(), false, WebDebugToolbarListener::ENABLED, $urlGenerator);
300300
$listener->onKernelResponse($event);
@@ -307,7 +307,7 @@ public function testCspIsDisabledIfDumperWasUsed()
307307
$response = new Response('<html><head></head><body></body></html>');
308308
$response->headers->set('X-Debug-Token', 'xxxxxxxx');
309309

310-
$event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MAIN_REQUEST, $response);
310+
$event = new ResponseEvent($this->createMock(Kernel::class), new Request(), HttpKernelInterface::MAIN_REQUEST, $response);
311311

312312
$cspHandler = $this->createMock(ContentSecurityPolicyHandler::class);
313313
$cspHandler->expects($this->once())
@@ -328,7 +328,7 @@ public function testCspIsKeptEnabledIfDumperWasNotUsed()
328328
$response = new Response('<html><head></head><body></body></html>');
329329
$response->headers->set('X-Debug-Token', 'xxxxxxxx');
330330

331-
$event = new ResponseEvent($this->createMock(Kernel::class), $this->getRequestMock(), HttpKernelInterface::MAIN_REQUEST, $response);
331+
$event = new ResponseEvent($this->createMock(Kernel::class), new Request(), HttpKernelInterface::MAIN_REQUEST, $response);
332332

333333
$cspHandler = $this->createMock(ContentSecurityPolicyHandler::class);
334334
$cspHandler->expects($this->never())
@@ -344,28 +344,6 @@ public function testCspIsKeptEnabledIfDumperWasNotUsed()
344344
$this->assertEquals("<html><head></head><body>\nWDT\n</body></html>", $response->getContent());
345345
}
346346

347-
protected function getRequestMock($isXmlHttpRequest = false, $requestFormat = 'html', $hasSession = true)
348-
{
349-
$request = $this->getMockBuilder(Request::class)->setMethods(['getSession', 'isXmlHttpRequest', 'getRequestFormat'])->disableOriginalConstructor()->getMock();
350-
$request->expects($this->any())
351-
->method('isXmlHttpRequest')
352-
->willReturn($isXmlHttpRequest);
353-
$request->expects($this->any())
354-
->method('getRequestFormat')
355-
->willReturn($requestFormat);
356-
357-
$request->headers = new HeaderBag();
358-
359-
if ($hasSession) {
360-
$session = $this->createMock(Session::class);
361-
$request->expects($this->any())
362-
->method('getSession')
363-
->willReturn($session);
364-
}
365-
366-
return $request;
367-
}
368-
369347
protected function getTwigMock($render = 'WDT')
370348
{
371349
$templating = $this->createMock(Environment::class);

src/Symfony/Component/ErrorHandler/Resources/views/exception_full.html.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,6 @@
2828
<span class="hidden-xs-down">Symfony</span> Docs
2929
</a>
3030
</div>
31-
32-
<div class="help-link">
33-
<a href="https://symfony.com/support">
34-
<span class="icon"><?= $this->include('assets/images/icon-support.svg'); ?></span>
35-
<span class="hidden-xs-down">Symfony</span> Support
36-
</a>
37-
</div>
3831
</div>
3932
</header>
4033
<?php } ?>

src/Symfony/Component/HttpKernel/HttpCache/Store.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ private function getMetadata(string $key): array
298298
return [];
299299
}
300300

301-
return unserialize($entries);
301+
return unserialize($entries) ?: [];
302302
}
303303

304304
/**

src/Symfony/Component/HttpKernel/Tests/EventListener/AddRequestFormatsListenerTest.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\HttpFoundation\Request;
1717
use Symfony\Component\HttpKernel\Event\RequestEvent;
1818
use Symfony\Component\HttpKernel\EventListener\AddRequestFormatsListener;
19+
use Symfony\Component\HttpKernel\HttpKernelInterface;
1920
use Symfony\Component\HttpKernel\KernelEvents;
2021

2122
/**
@@ -54,22 +55,12 @@ public function testRegisteredEvent()
5455
public function testSetAdditionalFormats()
5556
{
5657
$request = $this->createMock(Request::class);
57-
$event = $this->getRequestEventMock($request);
58+
$event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST);
5859

5960
$request->expects($this->once())
6061
->method('setFormat')
6162
->with('csv', ['text/csv', 'text/plain']);
6263

6364
$this->listener->onKernelRequest($event);
6465
}
65-
66-
protected function getRequestEventMock(Request $request)
67-
{
68-
$event = $this->createMock(RequestEvent::class);
69-
$event->expects($this->any())
70-
->method('getRequest')
71-
->willReturn($request);
72-
73-
return $event;
74-
}
7566
}

src/Symfony/Component/HttpKernel/Tests/EventListener/DisallowRobotsIndexingListenerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function testInvoke(?string $expected, array $responseArgs)
2929
$response = new Response(...$responseArgs);
3030
$listener = new DisallowRobotsIndexingListener();
3131

32-
$event = new ResponseEvent($this->createMock(HttpKernelInterface::class), $this->createMock(Request::class), KernelInterface::MAIN_REQUEST, $response);
32+
$event = new ResponseEvent($ 10AA3 this->createMock(HttpKernelInterface::class), new Request(), KernelInterface::MAIN_REQUEST, $response);
3333

3434
$listener->onResponse($event);
3535

src/Symfony/Component/HttpKernel/Tests/EventListener/SessionListenerTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@ public function testSessionIsSet()
6161
$request = new Request();
6262
$listener = new SessionListener($container);
6363

64-
$event = $this->createMock(RequestEvent::class);
65-
$event->expects($this->exactly(2))->method('isMainRequest')->willReturn(true);
66-
$event->expects($this->once())->method('getRequest')->willReturn($request);
64+
$event = new RequestEvent($this->createMock(HttpKernelInterface::class), $request, HttpKernelInterface::MAIN_REQUEST);
6765

6866
$listener->onKernelRequest($event);
6967

src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/PostgreSqlConnection.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ final class PostgreSqlConnection extends Connection
2828
* * get_notify_timeout: The length of time to wait for a response when calling PDO::pgsqlGetNotify, in milliseconds. Default: 0.
2929
*/
3030
protected const DEFAULT_OPTIONS = parent::DEFAULT_OPTIONS + [
31+
'use_notify' => true,
3132
'check_delayed_interval' => 60000,
3233
'get_notify_timeout' => 0,
3334
];

0 commit comments

Comments
 (0)
0