Merge branch '2.0' into 2.1

* 2.0:
  [EventDispatcher] Added assertion.
  [EventDispathcer] Fix removeListener

Conflicts:
	src/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php
This commit is contained in:
Fabien Potencier 2013-02-11 12:26:14 +01:00
commit 33aca01611
2 changed files with 24 additions and 1 deletions

View File

@ -106,7 +106,7 @@ class EventDispatcher implements EventDispatcherInterface
}
foreach ($this->listeners[$eventName] as $priority => $listeners) {
if (false !== ($key = array_search($listener, $listeners))) {
if (false !== ($key = array_search($listener, $listeners, true))) {
unset($this->listeners[$eventName][$priority][$key], $this->sorted[$eventName]);
}
}

View File

@ -244,6 +244,29 @@ class EventDispatcherTest extends \PHPUnit_Framework_TestCase
$this->dispatcher->dispatch('test');
$this->assertSame($this->dispatcher, $dispatcher);
}
/**
* @see https://bugs.php.net/bug.php?id=62976
*
* This bug affects:
* - The PHP 5.3 branch for versions < 5.3.18
* - The PHP 5.4 branch for versions < 5.4.8
* - The PHP 5.5 branch is not affected
*/
public function testWorkaroundForPhpBug62976()
{
$dispatcher = new EventDispatcher();
$dispatcher->addListener('bug.62976', new CallableClass());
$dispatcher->removeListener('bug.62976', function() {});
$this->assertTrue($dispatcher->hasListeners('bug.62976'));
}
}
class CallableClass
{
public function __invoke()
{
}
}
class TestEventListener