Skip to content

Commit d5de97d

Browse files
committed
Merge branch '4.4' into 5.1
* 4.4: fix merge drop logger mock in favor of using the BufferingLogger catch ValueError thrown on PHP 8 [Yaml Parser] Fix edge cases when parsing multiple documents fix parsing comments not prefixed by a space [Translator] Make sure a null locale is handled properly deal with errors being thrown on PHP 8 [Cache] Allow cache tags to be objects implementing __toString() [HttpKernel] Do not override max_redirects option in HttpClientKernel remove superfluous cast [HttpClient] Support for CURLOPT_LOCALPORT. Upgrade PHPUnit to 8.5 (php 7.2) and 9.3 (php >= 7.3). Fixed exception message formatting [FrameworkBundle] Fix error in xsd which prevent to register more than one metadata [Console] work around disabled putenv() [PhpUnitBridge] Fix error with ReflectionClass [HttpClient][HttpClientTrait] don't calculate alternatives if option is auth_ntlm Change 'cache_key' to AbstractRendererEngine::CACHE_KEY_VAR Upgrade PHPUnit to 8.5 (php 7.2) and 9.3 (php >= 7.3).
2 parents 94871fc + e17bb5e commit d5de97d

File tree

2 files changed

+35
-17
lines changed

2 files changed

+35
-17
lines changed

Tests/Debug/TraceableEventDispatcherTest.php

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\EventDispatcher\Tests\Debug;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\ErrorHandler\BufferingLogger;
1516
use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher;
1617
use Symfony\Component\EventDispatcher\EventDispatcher;
1718
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
@@ -192,41 +193,57 @@ public function testItDoesNotReturnHandledEvents()
192193

193194
public function testLogger()
194195
{
195-
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
196+
$logger = new BufferingLogger();
196197

197198
$dispatcher = new EventDispatcher();
198199
$tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch(), $logger);
199200
$tdispatcher->addListener('foo', $listener1 = function () {});
200201
$tdispatcher->addListener('foo', $listener2 = function () {});
201202

202-
$logger->expects($this->exactly(2))
203-
->method('debug')
204-
->withConsecutive(
205-
['Notified event "{event}" to listener "{listener}".', ['event' => 'foo', 'listener' => 'closure']],
206-
['Notified event "{event}" to listener "{listener}".', ['event' => 'foo', 'listener' => 'closure']]
207-
);
208-
209203
$tdispatcher->dispatch(new Event(), 'foo');
204+
205+
$this->assertSame([
206+
[
207+
'debug',
208+
'Notified event "{event}" to listener "{listener}".',
209+
['event' => 'foo', 'listener' => 'closure'],
210+
],
211+
[
212+
'debug',
213+
'Notified event "{event}" to listener "{listener}".',
214+
['event' => 'foo', 'listener' => 'closure'],
215+
],
216+
], $logger->cleanLogs());
210217
}
211218

212219
public function testLoggerWithStoppedEvent()
213220
{
214-
$logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();
221+
$logger = new BufferingLogger();
215222

216223
$dispatcher = new EventDispatcher();
217224
$tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch(), $logger);
218225
$tdispatcher->addListener('foo', $listener1 = function (Event $event) { $event->stopPropagation(); });
219226
$tdispatcher->addListener('foo', $listener2 = function () {});
220227

221-
$logger->expects($this->exactly(3))
222-
->method('debug')
223-
->withConsecutive(
224-
['Notified event "{event}" to listener "{listener}".', ['event' => 'foo', 'listener' => 'closure']],
225-
['Listener "{listener}" stopped propagation of the event "{event}".', ['event' => 'foo', 'listener' => 'closure']],
226-
['Listener "{listener}" was not called for event "{event}".', ['event' => 'foo', 'listener' => 'closure']]
227-
);
228-
229228
$tdispatcher->dispatch(new Event(), 'foo');
229+
230+
$this->assertSame([
231+
[
232+
'debug',
233+
'Notified event "{event}" to listener "{listener}".',
234+
['event' => 'foo', 'listener' => 'closure'],
235+
],
236+
[
237+
'debug',
238+
'Listener "{listener}" stopped propagation of the event "{event}".',
239+
['event' => 'foo', 'listener' => 'closure'],
240+
],
241+
[
242+
'debug',
243+
'Listener "{listener}" was not called for event "{event}".',
244+
['event' => 'foo', 'listener' => 'closure'],
245+
],
246+
], $logger->cleanLogs());
230247
}
231248

232249
public function testDispatchCallListeners()

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"symfony/dependency-injection": "^4.4|^5.0",
2626
"symfony/expression-language": "^4.4|^5.0",
2727
"symfony/config": "^4.4|^5.0",
28+
"symfony/error-handler": "^4.4|^5.0",
2829
"symfony/http-foundation": "^4.4|^5.0",
2930
"symfony/service-contracts": "^1.1|^2",
3031
"symfony/stopwatch": "^4.4|^5.0",

0 commit comments

Comments
 (0)