22
33namespace Enqueue \AmqpLib \Tests ;
44
5+ use Enqueue \AmqpLib \AmqpContext ;
56use Enqueue \AmqpLib \AmqpProducer ;
67use Enqueue \Test \ClassExtensionTrait ;
78use Interop \Amqp \Impl \AmqpMessage ;
@@ -23,7 +24,7 @@ class AmqpProducerTest extends TestCase
2324
2425 public function testCouldBeConstructedWithRequiredArguments ()
2526 {
26- new AmqpProducer ($ this ->createAmqpChannelMock ());
27+ new AmqpProducer ($ this ->createAmqpChannelMock (), $ this -> createContextMock () );
2728 }
2829
2930 public function testShouldImplementPsrProducerInterface ()
@@ -33,7 +34,7 @@ public function testShouldImplementPsrProducerInterface()
3334
3435 public function testShouldThrowExceptionWhenDestinationTypeIsInvalid ()
3536 {
36- $ producer = new AmqpProducer ($ this ->createAmqpChannelMock ());
37+ $ producer = new AmqpProducer ($ this ->createAmqpChannelMock (), $ this -> createContextMock () );
3738
3839 $ this ->expectException (InvalidDestinationException::class);
3940 $ this ->expectExceptionMessage ('The destination must be an instance of Interop\Amqp\AmqpQueue but got ' );
@@ -43,7 +44,7 @@ public function testShouldThrowExceptionWhenDestinationTypeIsInvalid()
4344
4445 public function testShouldThrowExceptionWhenMessageTypeIsInvalid ()
4546 {
46- $ producer = new AmqpProducer ($ this ->createAmqpChannelMock ());
47+ $ producer = new AmqpProducer ($ this ->createAmqpChannelMock (), $ this -> createContextMock () );
4748
4849 $ this ->expectException (InvalidMessageException::class);
4950 $ this ->expectExceptionMessage ('The message must be an instance of Interop\Amqp\AmqpMessage but it is ' );
@@ -70,7 +71,7 @@ public function testShouldPublishMessageToTopic()
7071 $ message = new AmqpMessage ('body ' );
7172 $ message ->setRoutingKey ('routing-key ' );
7273
73- $ producer = new AmqpProducer ($ channel );
74+ $ producer = new AmqpProducer ($ channel, $ this -> createContextMock () );
7475 $ producer ->send ($ topic , $ message );
7576
7677 $ this ->assertEquals ('body ' , $ amqpMessage ->getBody ());
@@ -92,7 +93,7 @@ public function testShouldPublishMessageToQueue()
9293
9394 $ queue = new AmqpQueue ('queue ' );
9495
95- $ producer = new AmqpProducer ($ channel );
96+ $ producer = new AmqpProducer ($ channel, $ this -> createContextMock () );
9697 $ producer ->send ($ queue , new AmqpMessage ('body ' ));
9798
9899 $ this ->assertEquals ('body ' , $ amqpMessage ->getBody ());
@@ -111,7 +112,7 @@ public function testShouldSetMessageHeaders()
111112 }))
112113 ;
113114
114- $ producer = new AmqpProducer ($ channel );
115+ $ producer = new AmqpProducer ($ channel, $ this -> createContextMock () );
115116 $ producer ->send (new AmqpTopic ('name ' ), new AmqpMessage ('body ' , [], ['content_type ' => 'text/plain ' ]));
116117
117118 $ this ->assertEquals (['content_type ' => 'text/plain ' ], $ amqpMessage ->get_properties ());
@@ -130,7 +131,7 @@ public function testShouldSetMessageProperties()
130131 }))
131132 ;
132133
133- $ producer = new AmqpProducer ($ channel );
134+ $ producer = new AmqpProducer ($ channel, $ this -> createContextMock () );
134135 $ producer ->send (new AmqpTopic ('name ' ), new AmqpMessage ('body ' , ['key ' => 'value ' ]));
135136
136137 $ properties = $ amqpMessage ->get_properties ();
@@ -163,4 +164,12 @@ private function createAmqpChannelMock()
163164 {
164165 return $ this ->createMock (AMQPChannel::class);
165166 }
167+
168+ /**
169+ * @return \PHPUnit_Framework_MockObject_MockObject|AmqpContext
170+ */
171+ private function createContextMock ()
172+ {
173+ return $ this ->createMock (AmqpContext::class);
174+ }
166175}
0 commit comments