10
10
11
11
use Magento \Framework \MessageQueue \PublisherInterface ;
12
12
use Magento \Framework \OsInfo ;
13
- use Magento \TestFramework \Helper \Bootstrap ;
14
13
use Magento \TestFramework \Helper \Amqp ;
15
14
16
15
class PublisherConsumerController
17
16
{
18
17
/**
19
- * @var string
18
+ * @var string[]
20
19
*/
21
20
private $ consumers = [];
22
21
@@ -50,11 +49,6 @@ class PublisherConsumerController
50
49
*/
51
50
private $ amqpHelper ;
52
51
53
- /**
54
- * @var ClearQueueProcessor
55
- */
56
- private $ clearQueueProcessor ;
57
-
58
52
/**
59
53
* PublisherConsumerController constructor.
60
54
* @param PublisherInterface $publisher
@@ -64,7 +58,6 @@ class PublisherConsumerController
64
58
* @param array $consumers
65
59
* @param array $appInitParams
66
60
* @param null|int $maxMessages
67
- * @param ClearQueueProcessor $clearQueueProcessor
68
61
*/
69
62
public function __construct (
70
63
PublisherInterface $ publisher ,
@@ -73,8 +66,7 @@ public function __construct(
73
66
$ logFilePath ,
74
67
$ consumers ,
75
68
$ appInitParams ,
76
- $ maxMessages = null ,
77
- ClearQueueProcessor $ clearQueueProcessor = null
69
+ $ maxMessages = null
78
70
) {
79
71
$ this ->consumers = $ consumers ;
80
72
$ this ->publisher = $ publisher ;
@@ -83,8 +75,6 @@ public function __construct(
83
75
$ this ->osInfo = $ osInfo ;
84
76
$ this ->appInitParams = $ appInitParams ;
85
77
$ this ->amqpHelper = $ amqpHelper ;
86
- $ this ->clearQueueProcessor = $ clearQueueProcessor
87
- ?: Bootstrap::getObjectManager ()->get (ClearQueueProcessor::class);
88
78
}
89
79
90
80
/**
@@ -97,7 +87,12 @@ public function initialize()
97
87
{
98
88
$ this ->validateEnvironmentPreconditions ();
99
89
100
- $ this ->clearQueueProcessor ->execute ("async.operations.all " );
90
+ $ connections = $ this ->amqpHelper ->getConnections ();
91
+ foreach (array_keys ($ connections ) as $ connectionName ) {
92
+ $ this ->amqpHelper ->deleteConnection ($ connectionName );
93
+ }
94
+ $ this ->amqpHelper ->clearQueue ("async.operations.all " );
95
+
101
96
$ this ->stopConsumers ();
102
97
$ this ->startConsumers ();
103
98
@@ -125,6 +120,12 @@ private function validateEnvironmentPreconditions()
125
120
"This test relies on *nix shell and should be skipped in Windows environment. "
126
121
);
127
122
}
123
+
124
+ if (!$ this ->amqpHelper ->isAvailable ()) {
125
+ throw new PreconditionFailedException (
126
+ 'This test relies on RabbitMQ Management Plugin. '
127
+ );
128
+ }
128
129
}
129
130
130
131
/**
0 commit comments