6
6
use Interop \Queue \PsrContext ;
7
7
use Interop \Queue \PsrMessage ;
8
8
use Interop \Queue \PsrQueue ;
9
+ use Interop \Queue \PsrSubscriptionConsumer ;
9
10
use Interop \Queue \PsrSubscriptionConsumerAwareContext ;
10
11
use PHPUnit \Framework \TestCase ;
11
12
@@ -19,6 +20,11 @@ abstract class SubscriptionConsumerConsumeUntilUnsubscribedSpec extends TestCase
19
20
*/
20
21
private $ context ;
21
22
23
+ /**
24
+ * @var PsrSubscriptionConsumer
25
+ */
26
+ protected $ subscriptionConsumer ;
27
+
22
28
protected function tearDown ()
23
29
{
24
30
if ($ this ->context ) {
@@ -50,19 +56,20 @@ public function test()
50
56
return true ;
51
57
};
52
58
53
- $ subscriptionConsumer = $ context ->createSubscriptionConsumer ();
59
+ $ this -> subscriptionConsumer = $ subscriptionConsumer = $ context ->createSubscriptionConsumer ();
54
60
$ subscriptionConsumer ->subscribe ($ fooConsumer , $ callback );
55
61
$ subscriptionConsumer ->subscribe ($ barConsumer , $ callback );
56
62
57
63
$ subscriptionConsumer ->consume (1000 );
58
64
59
65
$ this ->assertEquals (2 , $ consumedMessages );
60
66
67
+ $ subscriptionConsumer ->unsubscribe ($ fooConsumer );
68
+
61
69
$ context ->createProducer ()->send ($ fooQueue , $ context ->createMessage ());
62
70
$ context ->createProducer ()->send ($ barQueue , $ context ->createMessage ());
63
71
64
72
$ consumedMessages = 0 ;
65
- $ subscriptionConsumer ->unsubscribe ($ fooConsumer );
66
73
$ subscriptionConsumer ->consume (1000 );
67
74
68
75
$ this ->assertEquals (1 , $ consumedMessages );
0 commit comments