1010use Magento \Framework \Config \File \ConfigFilePool ;
1111use Magento \Framework \Filesystem ;
1212use Magento \Framework \MessageQueue \UseCase \QueueTestCaseAbstract ;
13+ use Magento \TestFramework \Helper \Bootstrap ;
1314use Magento \TestModuleAsyncStomp \Model \AsyncTestData ;
1415
1516class WaitAndNotWaitMessagesTest extends QueueTestCaseAbstract
@@ -49,24 +50,28 @@ class WaitAndNotWaitMessagesTest extends QueueTestCaseAbstract
4950 */
5051 protected $ maxMessages = 4 ;
5152
53+ /**
54+ * @var string
55+ */
56+ private $ connectionType ;
57+
5258 /**
5359 * @inheritdoc
5460 */
5561 protected function setUp (): void
5662 {
57- // Check if STOMP connection is available
58- try {
59- $ stompConfig = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()
60- ->get (\Magento \Framework \Stomp \Config::class);
61- $ stompConfig ->getConnection ();
62- } catch (\Exception $ e ) {
63- $ this ->markTestSkipped ('STOMP test skipped because AMQP connection is available. This test is STOMP-specific ' );
63+ $ this ->objectManager = Bootstrap::getObjectManager ();
64+ // Check if STOMP is configured as the queue connection
65+ /** @var \Magento\Framework\MessageQueue\DefaultValueProvider $defaultValueProvider */
66+ $ defaultValueProvider = $ this ->objectManager ->get (\Magento \Framework \MessageQueue \DefaultValueProvider::class);
67+ $ this ->connectionType = $ defaultValueProvider ->getConnection ();
68+
69+ if ($ this ->connectionType === 'stomp ' ) {
70+ parent ::setUp ();
71+ $ this ->reader = $ this ->objectManager ->get (FileReader::class);
72+ $ this ->filesystem = $ this ->objectManager ->get (Filesystem::class);
73+ $ this ->config = $ this ->loadConfig ();
6474 }
65-
66- parent ::setUp ();
67- $ this ->reader = $ this ->objectManager ->get (FileReader::class);
68- $ this ->filesystem = $ this ->objectManager ->get (Filesystem::class);
69- $ this ->config = $ this ->loadConfig ();
7075 }
7176
7277 /**
@@ -88,6 +93,10 @@ private function getMsgObject(): AsyncTestData
8893 */
8994 public function testWaitForMessages ()
9095 {
96+ if ($ this ->connectionType !== 'stomp ' ){
97+ $ this ->markTestSkipped ('STOMP test skipped because AMQP connection is available. This test is STOMP-specific. ' );
98+ }
99+
91100 $ this ->publisherConsumerController ->stopConsumers ();
92101
93102 $ config = $ this ->config ;
@@ -119,6 +128,10 @@ public function testWaitForMessages()
119128 */
120129 public function testNotWaitForMessages (): void
121130 {
131+ if ($ this ->connectionType !== 'stomp ' ){
132+ $ this ->markTestSkipped ('STOMP test skipped because AMQP connection is available. This test is STOMP-specific. ' );
133+ }
134+
122135 $ this ->publisherConsumerController ->stopConsumers ();
123136
124137 $ config = $ this ->config ;
0 commit comments