9
9
10
10
use Magento \Framework \MessageQueue \PoisonPill \PoisonPillCompareInterface ;
11
11
use Magento \Framework \MessageQueue \PoisonPill \PoisonPillReadInterface ;
12
- use Magento \Framework \ Shell ;
12
+ use Magento \MessageQueue \ Console \ RestartConsumerCommand ;
13
13
use Magento \TestFramework \Helper \Bootstrap ;
14
14
use PHPUnit \Framework \TestCase ;
15
+ use Symfony \Component \Console \Tester \CommandTester ;
15
16
16
- class PoisonPillAppyAfterCommandRunTest extends TestCase
17
+ class PoisonPillApplyAfterCommandRunTest extends TestCase
17
18
{
18
19
/**
19
20
* @var PoisonPillReadInterface
@@ -26,9 +27,9 @@ class PoisonPillAppyAfterCommandRunTest extends TestCase
26
27
private $ poisonPillCompare ;
27
28
28
29
/**
29
- * @var Shell
30
+ * @var RestartConsumerCommand
30
31
*/
31
- private $ shell ;
32
+ private $ restartConsumerCommand ;
32
33
33
34
/**
34
35
* @inheritdoc
@@ -38,19 +39,27 @@ protected function setUp(): void
38
39
$ objectManager = Bootstrap::getObjectManager ();
39
40
$ this ->poisonPillRead = $ objectManager ->get (PoisonPillReadInterface::class);
40
41
$ this ->poisonPillCompare = $ objectManager ->get (PoisonPillCompareInterface::class);
41
- $ this ->shell = $ objectManager ->get (Shell ::class);
42
+ $ this ->restartConsumerCommand = $ objectManager ->create (RestartConsumerCommand ::class);
42
43
}
43
44
44
45
/**
45
- * @throws \Magento\Framework\Exception\LocalizedException
46
46
* @covers \Magento\MessageQueue\Setup\Recurring
47
47
*
48
- * @magentoDbIsolation disabled
48
+ * @magentoDbIsolation enabled
49
49
*/
50
- public function testChangeVersion ()
50
+ public function testChangeVersion (): void
51
51
{
52
52
$ version = $ this ->poisonPillRead ->getLatestVersion ();
53
- $ this ->shell -> execute ( PHP_BINARY . ' -f %s queue:consumers:restart ' , [ BP . ' /bin/magento ' ] );
53
+ $ this ->runTestRestartConsumerCommand ( );
54
54
$ this ->assertEquals (false , $ this ->poisonPillCompare ->isLatestVersion ($ version ));
55
55
}
56
+
57
+ /**
58
+ * @return void
59
+ */
60
+ private function runTestRestartConsumerCommand (): void
61
+ {
62
+ $ commandTester = new CommandTester ($ this ->restartConsumerCommand );
63
+ $ commandTester ->execute ([]);
64
+ }
56
65
}
0 commit comments