6
6
7
7
namespace Magento \Framework \MessageQueue \Test \Unit ;
8
8
9
+ use Magento \Framework \MessageQueue \PoisonPill \PoisonPillCompareInterface ;
10
+ use Magento \Framework \MessageQueue \PoisonPill \PoisonPillReadInterface ;
9
11
use Magento \Framework \Phrase ;
10
12
11
13
/**
@@ -65,6 +67,16 @@ class ConsumerTest extends \PHPUnit\Framework\TestCase
65
67
*/
66
68
private $ consumer ;
67
69
70
+ /**
71
+ * @var PoisonPillReadInterface|\PHPUnit_Framework_MockObject_MockObject
72
+ */
73
+ private $ poisonPillRead ;
74
+
75
+ /**
76
+ * @var PoisonPillCompareInterface|\PHPUnit_Framework_MockObject_MockObject
77
+ */
78
+ private $ poisonPillCompare ;
79
+
68
80
/**
69
81
* Set up.
70
82
*
@@ -85,8 +97,15 @@ protected function setUp()
85
97
->disableOriginalConstructor ()->getMock ();
86
98
87
99
$ objectManager = new \Magento \Framework \TestFramework \Unit \Helper \ObjectManager ($ this );
100
+ $ this ->poisonPillCompare = $ this ->getMockBuilder (PoisonPillCompareInterface::class)
101
+ ->disableOriginalConstructor ()->getMock ();
102
+ $ this ->poisonPillRead = $ this ->getMockBuilder (PoisonPillReadInterface::class)
103
+ ->disableOriginalConstructor ()->getMock ();
88
104
//Hard dependency used because CallbackInvoker invokes closure logic defined inside of Customer class.
89
- $ this ->callbackInvoker = new \Magento \Framework \MessageQueue \CallbackInvoker ();
105
+ $ this ->callbackInvoker = new \Magento \Framework \MessageQueue \CallbackInvoker (
106
+ $ this ->poisonPillRead ,
107
+ $ this ->poisonPillCompare
108
+ );
90
109
$ this ->consumer = $ objectManager ->getObject (
91
110
\Magento \Framework \MessageQueue \Consumer::class,
92
111
[
@@ -134,7 +153,8 @@ public function testProcessWithNotFoundException()
134
153
$ numberOfMessages = 1 ;
135
154
$ consumerName = 'consumer.name ' ;
136
155
$ exceptionPhrase = new Phrase ('Exception successfully thrown ' );
137
-
156
+ $ this ->poisonPillRead ->expects ($ this ->atLeastOnce ())->method ('getLatestVersion ' )->willReturn ('version-1 ' );
157
+ $ this ->poisonPillCompare ->expects ($ this ->atLeastOnce ())->method ('isLatestVersion ' )->willReturn (true );
138
158
$ queue = $ this ->getMockBuilder (\Magento \Framework \MessageQueue \QueueInterface::class)
139
159
->disableOriginalConstructor ()->getMock ();
140
160
$ this ->configuration ->expects ($ this ->once ())->method ('getQueue ' )->willReturn ($ queue );
0 commit comments