Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'hotfix/3685' of git://github.com/wryck7/zf2 into wryck7-hotfix/3685
  • Loading branch information
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/EventManager.php
Expand Up @@ -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)));
}
Expand Down
15 changes: 13 additions & 2 deletions test/EventManagerTest.php
Expand Up @@ -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()
Expand All @@ -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()
Expand Down

0 comments on commit 923e54a

Please sign in to comment.