Skip to content

Commit b81b65b

Browse files
committed
[EventDispatcher] fixed deprecation notices in the EventDispatcher Component
1 parent f812eb8 commit b81b65b

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

GenericEvent.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function getArgument($key)
7171
return $this->arguments[$key];
7272
}
7373

74-
throw new \InvalidArgumentException(sprintf('%s not found in %s', $key, $this->getName()));
74+
throw new \InvalidArgumentException(sprintf('Argument "%s" not found.', $key));
7575
}
7676

7777
/**

Tests/AbstractEventDispatcherTest.php

+12-2
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,18 @@ public function testDispatch()
118118
$this->assertInstanceOf('Symfony\Component\EventDispatcher\Event', $this->dispatcher->dispatch(self::preFoo));
119119
$event = new Event();
120120
$return = $this->dispatcher->dispatch(self::preFoo, $event);
121-
$this->assertEquals('pre.foo', $event->getName());
122121
$this->assertSame($event, $return);
123122
}
124123

124+
public function testLegacyDispatch()
125+
{
126+
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
127+
128+
$event = new Event();
129+
$return = $this->dispatcher->dispatch(self::preFoo, $event);
130+
$this->assertEquals('pre.foo', $event->getName());
131+
}
132+
125133
public function testDispatchForClosure()
126134
{
127135
$invoked = 0;
@@ -239,8 +247,10 @@ public function testRemoveSubscriberWithMultipleListeners()
239247
$this->assertFalse($this->dispatcher->hasListeners(self::preFoo));
240248
}
241249

242-
public function testEventReceivesTheDispatcherInstance()
250+
public function testLegacyEventReceivesTheDispatcherInstance()
243251
{
252+
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
253+
244254
$dispatcher = null;
245255
$this->dispatcher->addListener('test', function ($event) use (&$dispatcher) {
246256
$dispatcher = $event->getDispatcher();

0 commit comments

Comments
 (0)