Skip to content

Commit bafaf13

Browse files
author
Omer Lakraa
committed
Fix tests
1 parent e36d996 commit bafaf13

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,23 +613,27 @@ public function testExceptionsConfig()
613613
\Symfony\Component\HttpKernel\Exception\ConflictHttpException::class,
614614
\Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException::class,
615615
], array_keys($configuration));
616-
616+
617617
$this->assertEqualsCanonicalizing([
618+
'log_channel' => null,
618619
'log_level' => 'info',
619620
'status_code' => 422,
620621
], $configuration[\Symfony\Component\HttpKernel\Exception\BadRequestHttpException::class]);
621622

622623
$this->assertEqualsCanonicalizing([
624+
'log_channel' => null,
623625
'log_level' => 'info',
624626
'status_code' => null,
625627
], $configuration[\Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class]);
626628

627629
$this->assertEqualsCanonicalizing([
630+
'log_channel' => null,
628631
'log_level' => 'info',
629632
'status_code' => null,
630633
], $configuration[\Symfony\Component\HttpKernel\Exception\ConflictHttpException::class]);
631634

632635
$this->assertEqualsCanonicalizing([
636+
'log_channel' => null,
633637
'log_level' => null,
634638
'status_code' => 500,
635639
], $configuration[\Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException::class]);

src/Symfony/Component/HttpKernel/EventListener/ErrorListener.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function logKernelException(ExceptionEvent $event): void
6262
}
6363
break;
6464
}
65-
65+
6666
// There's no specific status code defined in the configuration for this exception
6767
if (!$throwable instanceof HttpExceptionInterface && $withHttpStatus = $this->getInheritedAttribute($throwable::class, WithHttpStatus::class)) {
6868
$throwable = HttpException::fromStatusCode($withHttpStatus->statusCode, $throwable->getMessage(), $throwable, $withHttpStatus->headers);
@@ -167,7 +167,7 @@ public static function getSubscribedEvents(): array
167167
protected function logException(\Throwable $exception, string $message, ?string $logLevel = null, /* ?string $logChannel = null */): void
168168
{
169169
$logChannel = (3 < \func_num_args() ? \func_get_arg(3) : null) ?? $this->resolveLogChannel($exception);
170-
170+
171171
$logLevel ??= $this->resolveLogLevel($exception);
172172

173173
if(!$logger = $this->getLogger($logChannel)) {

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

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,10 @@ public function testHandleWithLogChannel()
166166
$l->logKernelException($event);
167167
$l->onKernelException($event);
168168

169-
$this->assertEquals(new Response('foo', 401), $event->getResponse());
170-
$this->assertCount(0, $defaultLogger->getLogs('error'));
171-
$this->assertCount(0, $defaultLogger->getLogs('warning'));
172-
$this->assertCount(0, $channelLoger->getLogs('error'));
173-
$this->assertCount(1, $channelLoger->getLogs('warning'));
169+
$this->assertCount(0, $defaultLogger->getLogsForLevel('error'));
170+
$this->assertCount(0, $defaultLogger->getLogsForLevel('warning'));
171+
$this->assertCount(0, $channelLoger->getLogsForLevel('error'));
172+
$this->assertCount(1, $channelLoger->getLogsForLevel('warning'));
174173
}
175174

176175
public function testHandleWithLoggerChannelNotUsed()
@@ -193,14 +192,12 @@ public function testHandleWithLoggerChannelNotUsed()
193192
$l->logKernelException($event);
194193
$l->onKernelException($event);
195194

196-
$this->assertEquals(new Response('foo', 401), $event->getResponse());
197-
198195
$this->assertSame(0, $defaultLogger->countErrors());
199-
$this->assertCount(0, $defaultLogger->getLogs('critical'));
200-
$this->assertCount(1, $defaultLogger->getLogs('warning'));
201-
$this->assertCount(0, $channelLoger->getLogs('warning'));
202-
$this->assertCount(0, $channelLoger->getLogs('error'));
203-
$this->assertCount(0, $channelLoger->getLogs('critical'));
196+
$this->assertCount(0, $defaultLogger->getLogsForLevel('critical'));
197+
$this->assertCount(1, $defaultLogger->getLogsForLevel('warning'));
198+
$this->assertCount(0, $channelLoger->getLogsForLevel('warning'));
199+
$this->assertCount(0, $channelLoger->getLogsForLevel('error'));
200+
$this->assertCount(0, $channelLoger->getLogsForLevel('critical'));
204201
}
205202

206203
public function testHandleClassImplementingInterfaceWithLogLevelAttribute()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy