File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed
test/Bitbucket/Tests/API/Http Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -101,9 +101,12 @@ public function hasListeners()
101101 */
102102 public function setListeners (array $ listeners )
103103 {
104- foreach ($ listeners as $ prio => $ listener ) {
104+ foreach ($ listeners as $ priority => $ listener ) {
105105 $ listener = array_values ($ listener );
106- $ this ->addListener ($ listener [0 ], $ prio );
106+
107+ foreach ($ listener as $ samePriorityListener ) {
108+ $ this ->addListener ($ samePriorityListener , $ priority );
109+ }
107110 }
108111
109112 return $ this ;
Original file line number Diff line number Diff line change 22
33namespace Bitbucket \Tests \API \Http ;
44
5+ use Bitbucket \API \Http \Listener \NormalizeArrayListener ;
6+ use Bitbucket \API \Http \Listener \OAuthListener ;
57use Bitbucket \Tests \API as Tests ;
68use Bitbucket \API \Http \Client ;
79use Buzz \Client \Curl ;
@@ -163,6 +165,23 @@ public function testGetAbsentListener()
163165 $ this ->client ->getListener ('invalid ' );
164166 }
165167
168+ public function testSetListenersWorksWithMultipleListeners ()
169+ {
170+ $ listeners = array (
171+ '0 ' => array (
172+ new NormalizeArrayListener (),
173+ new OAuthListener (array ()),
174+ )
175+ );
176+
177+ $ this ->client ->setListeners ($ listeners );
178+
179+ $ listeners = $ this ->client ->getListeners ();
180+
181+ $ this ->assertArrayHasKey ('normalize_array ' , $ listeners [0 ]);
182+ $ this ->assertArrayHasKey ('oauth ' , $ listeners [0 ]);
183+ }
184+
166185 private function getListenerMock ($ name = 'dummy ' )
167186 {
168187 $ listener = $ this ->getMock ('Bitbucket\API\Http\Listener\ListenerInterface ' );
You can’t perform that action at this time.
0 commit comments