Permalink
Browse files

fix for issue #3685

  • Loading branch information...
1 parent 087f459 commit 25957e692b4c577fe045ce35084ffee46d42e066 @iquabius committed Mar 13, 2013
Showing with 14 additions and 3 deletions.
  1. +1 −1 library/Zend/EventManager/EventManager.php
  2. +13 −2 tests/ZendTest/EventManager/EventManagerTest.php
@@ -157,7 +157,7 @@ public function setIdentifiers($identifiers)
public function addIdentifiers($identifiers)
{
if (is_array($identifiers) || $identifiers instanceof Traversable) {
- $this->identifiers = array_unique($this->identifiers + (array) $identifiers);
+ $this->identifiers = array_unique(array_merge($this->identifiers, (array) $identifiers));
} elseif ($identifiers !== null) {
$this->identifiers = array_unique(array_merge($this->identifiers, array($identifiers)));
}
@@ -592,7 +592,12 @@ public function testIdentifierGetterSettersWorkWithArrays()
$this->assertSame($this->events->getIdentifiers(), $identifiers);
$identifiers[] = 'baz';
$this->assertInstanceOf('Zend\EventManager\EventManager', $this->events->addIdentifiers($identifiers));
- $this->assertSame($this->events->getIdentifiers(), $identifiers);
+
+ // This is done because the keys doesn't matter, just the values
+ $expectedIdentifiers = $this->events->getIdentifiers();
+ sort($expectedIdentifiers);
+ sort($identifiers);
+ $this->assertSame($expectedIdentifiers, $identifiers);
}
public function testIdentifierGetterSettersWorkWithTraversables()
@@ -602,7 +607,13 @@ public function testIdentifierGetterSettersWorkWithTraversables()
$this->assertSame($this->events->getIdentifiers(), (array) $identifiers);
$identifiers = new ArrayIterator(array('foo', 'bar', 'baz'));
$this->assertInstanceOf('Zend\EventManager\EventManager', $this->events->addIdentifiers($identifiers));
- $this->assertSame($this->events->getIdentifiers(), (array) $identifiers);
+
+ // This is done because the keys doesn't matter, just the values
+ $expectedIdentifiers = $this->events->getIdentifiers();
+ sort($expectedIdentifiers);
+ $identifiers = (array) $identifiers;
+ sort($identifiers);
+ $this->assertSame($expectedIdentifiers, $identifiers);
}
public function testListenersAttachedWithWildcardAreTriggeredForAllEvents()

0 comments on commit 25957e6

Please sign in to comment.