This repository has been archived by the owner on Jan 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prepping for 2.2.0RC1.
- Loading branch information
144 parents
226510f
+
6d779b2
+
ae8a2d3
+
b2b7d74
+
d748fa1
+
dab45d1
+
cdb0e25
+
55ca933
+
58174bc
+
1804746
+
67c0075
+
e5983dd
+
a8b3425
+
a2a193a
+
33d1c27
+
1d5cfa1
+
460ae0b
+
c577f06
+
db33b2e
+
fea371a
+
c93bbae
+
a4ff530
+
cbd4621
+
4b4dffb
+
00380d2
+
3895f9f
+
6349844
+
b6905a7
+
b7735a0
+
8312aef
+
7be4333
+
8625190
+
4dd38f5
+
e02bd81
+
87c797f
+
73208bf
+
0272cd1
+
1fcbea4
+
197a891
+
5859e98
+
d34ef1c
+
e06dc2f
+
4907ff6
+
fd0e0ba
+
891fbf7
+
83d5b01
+
4579f15
+
c86ed1e
+
16b8f20
+
83086b6
+
a81c8a5
+
a85d989
+
55ef06c
+
a2d63b1
+
8210d1d
+
0a08fc0
+
7d37340
+
ab0ab2a
+
b9e0b9b
+
e1d4bda
+
e251276
+
161ba87
+
f10c77c
+
58cc6ef
+
cecfbb0
+
c165fb8
+
1febb29
+
3325e48
+
8b68fab
+
43c1b37
+
ec52465
+
2904103
+
e4d7a5a
+
be7b13f
+
f8dd43d
+
b1b3322
+
93ccc75
+
2d494af
+
25e9a69
+
3f70aa8
+
598d6ed
+
8161582
+
c01dc55
+
98634fe
+
0c55546
+
1c83b8f
+
815d8cc
+
19c90c8
+
5dbf1b9
+
4a927fd
+
4a648ec
+
d0636ac
+
840f139
+
aafb3ee
+
8600965
+
b26220b
+
860ba0d
+
759cd42
+
eebf7bc
+
6546e0d
+
11d36d3
+
4a1db1e
+
04eebff
+
892dcff
+
b878b24
+
2db85a1
+
97242e6
+
9ee6b4d
+
13fabed
+
8fe32d7
+
035474f
+
918b5da
+
8d65fb0
+
1f16b54
+
282eead
+
cb64f10
+
491c672
+
e10e997
+
93858ca
+
d41e72e
+
9af5add
+
309bc00
+
984be73
+
be29716
+
41232e8
+
1b6d07e
+
8cd4674
+
ee1d485
+
e5aa383
+
fc3991f
+
ba6e7b6
+
90ecccb
+
b1db52f
+
ef24a14
+
ae89a5d
+
2963b07
+
ce1dffc
+
6fa20e6
+
b20a39d
+
5174cf5
+
0c36811
+
486ca02
+
f995ad2
+
c4edf83
commit f7ed875
Showing
8 changed files
with
279 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
/** | ||
* Zend Framework (http://framework.zend.com/) | ||
* | ||
* @link http://github.com/zendframework/zf2 for the canonical source repository | ||
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
*/ | ||
|
||
namespace Zend\EventManager; | ||
|
||
|
||
/** | ||
* Abstract aggregate listener | ||
*/ | ||
abstract class AbstractListenerAggregate implements ListenerAggregateInterface | ||
{ | ||
/** | ||
* @var \Zend\Stdlib\CallbackHandler[] | ||
*/ | ||
protected $listeners = array(); | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function detach(EventManagerInterface $events) | ||
{ | ||
foreach ($this->listeners as $index => $callback) { | ||
if ($events->detach($callback)) { | ||
unset($this->listeners[$index]); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
/** | ||
* Zend Framework (http://framework.zend.com/) | ||
* | ||
* @link http://github.com/zendframework/zf2 for the canonical source repository | ||
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
*/ | ||
|
||
namespace Zend\EventManager; | ||
|
||
/** | ||
* Provides logic to easily create aggregate listeners, without worrying about | ||
* manually detaching events | ||
*/ | ||
trait ListenerAggregateTrait | ||
{ | ||
/** | ||
* @var \Zend\Stdlib\CallbackHandler[] | ||
*/ | ||
protected $listeners = array(); | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function detach(EventManagerInterface $events) | ||
{ | ||
foreach ($this->listeners as $index => $callback) { | ||
if ($events->detach($callback)) { | ||
unset($this->listeners[$index]); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
/** | ||
* Zend Framework (http://framework.zend.com/) | ||
* | ||
* @link http://github.com/zendframework/zf2 for the canonical source repository | ||
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
* @package Zend_EventManager | ||
*/ | ||
|
||
namespace ZendTest\EventManager; | ||
|
||
use ZendTest\EventManager\TestAsset\MockAbstractListenerAggregate; | ||
|
||
/** | ||
* @category Zend | ||
* @package Zend_EventManager | ||
* @subpackage UnitTests | ||
* @group Zend_EventManager | ||
*/ | ||
class AbstractListenerAggregateTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var \ZendTest\EventManager\TestAsset\MockAbstractListenerAggregate | ||
*/ | ||
protected $listener; | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function setUp() | ||
{ | ||
$this->listener = new MockAbstractListenerAggregate(); | ||
} | ||
|
||
/** | ||
* @covers \Zend\EventManager\AbstractListenerAggregate::detach | ||
*/ | ||
public function testDetach() | ||
{ | ||
$eventManager = $this->getMock('Zend\\EventManager\\EventManagerInterface'); | ||
$unrelatedEventManager = $this->getMock('Zend\\EventManager\\EventManagerInterface'); | ||
$callbackHandlers = array(); | ||
$test = $this; | ||
|
||
$eventManager | ||
->expects($this->exactly(2)) | ||
->method('attach') | ||
->will($this->returnCallback(function () use (&$callbackHandlers, $test) { | ||
return $callbackHandlers[] = $test->getMock('Zend\\Stdlib\\CallbackHandler', array(), array(), '', false); | ||
})); | ||
|
||
$this->listener->attach($eventManager); | ||
$this->assertSame($callbackHandlers, $this->listener->getCallbacks()); | ||
|
||
$this->listener->detach($unrelatedEventManager); | ||
|
||
$this->assertSame($callbackHandlers, $this->listener->getCallbacks()); | ||
|
||
$eventManager | ||
->expects($this->exactly(2)) | ||
->method('detach') | ||
->with($this->callback(function ($callbackHandler) use ($callbackHandlers) { | ||
return in_array($callbackHandler, $callbackHandlers, true); | ||
})) | ||
->will($this->returnValue(true)); | ||
|
||
$this->listener->detach($eventManager); | ||
$this->assertEmpty($this->listener->getCallbacks()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
/** | ||
* Zend Framework (http://framework.zend.com/) | ||
* | ||
* @link http://github.com/zendframework/zf2 for the canonical source repository | ||
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
* @package Zend_EventManager | ||
*/ | ||
|
||
namespace ZendTest\EventManager; | ||
|
||
use ZendTest\EventManager\TestAsset\MockListenerAggregateTrait; | ||
|
||
/** | ||
* @requires PHP 5.4 | ||
*/ | ||
class ListenerAggregateTraitTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @covers \Zend\EventManager\ListenerAggregateTrait::detach | ||
*/ | ||
public function testDetach() | ||
{ | ||
$listener = new MockListenerAggregateTrait(); | ||
$eventManager = $this->getMock('Zend\\EventManager\\EventManagerInterface'); | ||
$unrelatedEventManager = $this->getMock('Zend\\EventManager\\EventManagerInterface'); | ||
$callbackHandlers = array(); | ||
$test = $this; | ||
|
||
$eventManager | ||
->expects($this->exactly(2)) | ||
->method('attach') | ||
->will($this->returnCallback(function () use (&$callbackHandlers, $test) { | ||
return $callbackHandlers[] = $test->getMock('Zend\\Stdlib\\CallbackHandler', array(), array(), '', false); | ||
})); | ||
|
||
$listener->attach($eventManager); | ||
$this->assertSame($callbackHandlers, $listener->getCallbacks()); | ||
|
||
$listener->detach($unrelatedEventManager); | ||
|
||
$this->assertSame($callbackHandlers, $listener->getCallbacks()); | ||
|
||
$eventManager | ||
->expects($this->exactly(2)) | ||
->method('detach') | ||
->with($this->callback(function ($callbackHandler) use ($callbackHandlers) { | ||
return in_array($callbackHandler, $callbackHandlers, true); | ||
})) | ||
->will($this->returnValue(true)); | ||
|
||
$listener->detach($eventManager); | ||
$this->assertEmpty($listener->getCallbacks()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
/** | ||
* Zend Framework (http://framework.zend.com/) | ||
* | ||
* @link http://github.com/zendframework/zf2 for the canonical source repository | ||
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
* @package Zend_EventManager | ||
*/ | ||
|
||
namespace ZendTest\EventManager\TestAsset; | ||
|
||
use Zend\EventManager\AbstractListenerAggregate; | ||
use Zend\EventManager\EventManagerInterface; | ||
|
||
/** | ||
* @category Zend | ||
* @package Zend_EventManager | ||
* @subpackage UnitTests | ||
* @group Zend_EventManager | ||
*/ | ||
class MockAbstractListenerAggregate extends AbstractListenerAggregate | ||
{ | ||
public $priority; | ||
|
||
public function attach(EventManagerInterface $events) | ||
{ | ||
$this->listeners[] = $events->attach('foo.bar', array($this, 'doFoo')); | ||
$this->listeners[] = $events->attach('foo.baz', array($this, 'doFoo')); | ||
} | ||
|
||
public function getCallbacks() | ||
{ | ||
return $this->listeners; | ||
} | ||
|
||
public function doFoo() | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
/** | ||
* Zend Framework (http://framework.zend.com/) | ||
* | ||
* @link http://github.com/zendframework/zf2 for the canonical source repository | ||
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license http://framework.zend.com/license/new-bsd New BSD License | ||
* @package Zend_EventManager | ||
*/ | ||
|
||
namespace ZendTest\EventManager\TestAsset; | ||
|
||
use Zend\EventManager\EventManagerInterface; | ||
use Zend\EventManager\ListenerAggregateTrait; | ||
|
||
/** | ||
* @category Zend | ||
* @package Zend_EventManager | ||
* @subpackage UnitTests | ||
* @group Zend_EventManager | ||
*/ | ||
class MockListenerAggregateTrait | ||
{ | ||
use ListenerAggregateTrait; | ||
|
||
public function attach(EventManagerInterface $events) | ||
{ | ||
$this->listeners[] = $events->attach('foo.bar', array($this, 'doFoo')); | ||
$this->listeners[] = $events->attach('foo.baz', array($this, 'doFoo')); | ||
} | ||
|
||
public function getCallbacks() | ||
{ | ||
return $this->listeners; | ||
} | ||
|
||
public function doFoo() | ||
{ | ||
} | ||
} |