44
55use Enqueue \Consumption \ChainExtension ;
66use Enqueue \Consumption \Context ;
7+ use Enqueue \Consumption \Context \PreSubscribe ;
78use Enqueue \Consumption \Context \Start ;
89use Enqueue \Consumption \ExtensionInterface ;
910use Enqueue \Test \ClassExtensionTrait ;
@@ -26,7 +27,7 @@ public function testCouldBeConstructedWithExtensionsArray()
2627
2728 public function testShouldProxyOnStartToAllInternalExtensions ()
2829 {
29- $ context = new Start ($ this ->createMock (\ Interop \ Queue \Context::class ), $ this ->createLoggerMock (), [], 0 , 0 , 0 );
30+ $ context = new Start ($ this ->createInteropContextMock ( ), $ this ->createLoggerMock (), [], 0 , 0 , 0 );
3031
3132 $ fooExtension = $ this ->createExtension ();
3233 $ fooExtension
@@ -46,6 +47,33 @@ public function testShouldProxyOnStartToAllInternalExtensions()
4647 $ extensions ->onStart ($ context );
4748 }
4849
50+ public function testShouldProxyPreSubscribeToAllInternalExtensions ()
51+ {
52+ $ context = new PreSubscribe (
53+ $ this ->createInteropContextMock (),
54+ $ this ->createInteropProcessorMock (),
55+ $ this ->createInteropConsumerMock (),
56+ $ this ->createLoggerMock ()
57+ );
58+
59+ $ fooExtension = $ this ->createExtension ();
60+ $ fooExtension
61+ ->expects ($ this ->once ())
62+ ->method ('preSubscribe ' )
63+ ->with ($ this ->identicalTo ($ context ))
64+ ;
65+ $ barExtension = $ this ->createExtension ();
66+ $ barExtension
67+ ->expects ($ this ->once ())
68+ ->method ('preSubscribe ' )
69+ ->with ($ this ->identicalTo ($ context ))
70+ ;
71+
72+ $ extensions = new ChainExtension ([$ fooExtension , $ barExtension ]);
73+
74+ $ extensions ->preSubscribe ($ context );
75+ }
76+
4977 public function testShouldProxyOnBeforeReceiveToAllInternalExtensions ()
5078 {
5179 $ context = $ this ->createContextMock ();
@@ -186,6 +214,30 @@ protected function createLoggerMock(): LoggerInterface
186214 return $ this ->createMock (LoggerInterface::class);
187215 }
188216
217+ /**
218+ * @return \PHPUnit_Framework_MockObject_MockObject
219+ */
220+ protected function createInteropContextMock (): \Interop \Queue \Context
221+ {
222+ return $ this ->createMock (\Interop \Queue \Context::class);
223+ }
224+
225+ /**
226+ * @return \PHPUnit_Framework_MockObject_MockObject
227+ */
228+ protected function createInteropConsumerMock (): \Interop \Queue \Consumer
229+ {
230+ return $ this ->createMock (\Interop \Queue \Consumer::class);
231+ }
232+
233+ /**
234+ * @return \PHPUnit_Framework_MockObject_MockObject
235+ */
236+ protected function createInteropProcessorMock (): \Interop \Queue \Processor
237+ {
238+ return $ this ->createMock (\Interop \Queue \Processor::class);
239+ }
240+
189241 /**
190242 * @return \PHPUnit_Framework_MockObject_MockObject|Context
191243 */
0 commit comments