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 \Setup \ Console \ Command \ UpgradeCommand ;
13
13
use Magento \TestFramework \Helper \Bootstrap ;
14
14
use PHPUnit \Framework \TestCase ;
15
+ use Symfony \Component \Console \Tester \CommandTester ;
15
16
16
17
class PoisonPillApplyDuringSetupUpgradeTest extends TestCase
17
18
{
@@ -26,9 +27,9 @@ class PoisonPillApplyDuringSetupUpgradeTest extends TestCase
26
27
private $ poisonPillCompare ;
27
28
28
29
/**
29
- * @var Shell
30
+ * @var UpgradeCommand
30
31
*/
31
- private $ shell ;
32
+ private $ upgradeCommand ;
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 ->upgradeCommand = $ objectManager ->get (UpgradeCommand ::class);
42
43
}
43
44
44
45
/**
45
- * @throws \Magento\Framework\Exception\LocalizedException
46
46
* @covers \Magento\MessageQueue\Setup\Recurring
47
47
*
48
48
* @magentoDbIsolation disabled
49
49
*/
50
50
public function testChangeVersion ()
51
51
{
52
52
$ version = $ this ->poisonPillRead ->getLatestVersion ();
53
- $ this ->shell -> execute ( PHP_BINARY . ' -f %s setup:upgrade --keep-generated ' , [ BP . ' /bin/magento ' ] );
53
+ $ this ->runTestUpgradeCommand ( );
54
54
$ this ->assertEquals (false , $ this ->poisonPillCompare ->isLatestVersion ($ version ));
55
55
}
56
+
57
+ /**
58
+ * @return void
59
+ */
60
+ private function runTestUpgradeCommand (): void
61
+ {
62
+ $ commandTester = new CommandTester ($ this ->upgradeCommand );
63
+ $ commandTester ->execute (['--keep-generated ' ]);
64
+ }
56
65
}
0 commit comments