Skip to content

Commit 844ece3

Browse files
committed
at method deprecation fix
1 parent a1c363e commit 844ece3

File tree

3 files changed

+44
-24
lines changed

3 files changed

+44
-24
lines changed

src/Test/Unit/Service/EolValidatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function testCompatibleVersion()
9999
->willReturn(true);
100100

101101
$serviceName = ServiceInterface::NAME_ELASTICSEARCH;
102-
$serviceVersion = '6.5';
102+
$serviceVersion = '8.11';
103103

104104
$this->assertEquals([], $this->validator->validateService($serviceName, $serviceVersion));
105105
}

src/Test/Unit/Step/Build/EnableEventingTest.php

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use PHPUnit\Framework\MockObject\MockObject;
1919
use PHPUnit\Framework\TestCase;
2020
use Psr\Log\LoggerInterface;
21+
use Magento\MagentoCloud\Shell\ProcessInterface;
2122

2223
/**
2324
* @inheritDoc
@@ -44,6 +45,11 @@ class EnableEventingTest extends TestCase
4445
*/
4546
private $globalConfigMock;
4647

48+
/**
49+
* @var ProcessInterface|MockObject
50+
*/
51+
private $processMock;
52+
4753
/**
4854
* @inheritdoc
4955
*/
@@ -63,6 +69,7 @@ protected function setUp(): void
6369
$shellFactoryMock,
6470
$this->globalConfigMock
6571
);
72+
$this->processMock = $this->getMockForAbstractClass(ProcessInterface::class);
6673
}
6774

6875
/**
@@ -124,13 +131,15 @@ public function testExecuteEnableModuleCommandFailed()
124131
->method('get')
125132
->with(StageConfigInterface::VAR_ENABLE_EVENTING)
126133
->willReturn(true);
127-
$this->magentoShellMock->expects(self::at(0))
128-
->method('execute')
129-
->with('events:generate:module');
130-
$this->magentoShellMock->expects(self::at(1))
131-
->method('execute')
132-
->with('module:enable Magento_AdobeCommerceEvents')
133-
->willThrowException(new ShellException('error during module enablement'));
134+
$this->magentoShellMock->expects(self::exactly(2))
135+
->method('execute')
136+
->willReturnCallback(function ($arg1) {
137+
if ($arg1 == 'events:generate:module') {
138+
return $this->processMock;
139+
} elseif ($arg1 == 'module:enable Magento_AdobeCommerceEvents') {
140+
throw new ShellException('error during module enablement');
141+
}
142+
});
134143
$this->loggerMock->expects(self::exactly(2))
135144
->method('notice');
136145
$this->loggerMock->expects(self::once())
@@ -149,12 +158,13 @@ public function testExecuteSuccess()
149158
->method('get')
150159
->with(StageConfigInterface::VAR_ENABLE_EVENTING)
151160
->willReturn(true);
152-
$this->magentoShellMock->expects(self::at(0))
153-
->method('execute')
154-
->with('events:generate:module');
155-
$this->magentoShellMock->expects(self::at(1))
161+
$this->magentoShellMock->expects(self::any())
156162
->method('execute')
157-
->with('module:enable Magento_AdobeCommerceEvents');
163+
->willReturnCallback(function ($arg1) {
164+
if ($arg1 == 'events:generate:module' || $arg1 == 'module:enable Magento_AdobeCommerceEvents') {
165+
return $this->processMock;
166+
}
167+
});
158168
$this->loggerMock->expects(self::exactly(2))
159169
->method('notice');
160170
$this->loggerMock->expects(self::never())

src/Test/Unit/Step/Build/EnableWebhooksTest.php

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use PHPUnit\Framework\MockObject\MockObject;
1919
use PHPUnit\Framework\TestCase;
2020
use Psr\Log\LoggerInterface;
21+
use Magento\MagentoCloud\Shell\ProcessInterface;
2122

2223
/**
2324
* @inheritDoc
@@ -44,6 +45,11 @@ class EnableWebhooksTest extends TestCase
4445
*/
4546
private $globalConfigMock;
4647

48+
/**
49+
* @var ProcessInterface|MockObject
50+
*/
51+
private $processMock;
52+
4753
/**
4854
* @inheritdoc
4955
*/
@@ -63,6 +69,7 @@ protected function setUp(): void
6369
$shellFactoryMock,
6470
$this->globalConfigMock
6571
);
72+
$this->processMock = $this->getMockForAbstractClass(ProcessInterface::class);
6673
}
6774

6875
/**
@@ -124,13 +131,15 @@ public function testExecuteEnableModuleCommandFailed()
124131
->method('get')
125132
->with(StageConfigInterface::VAR_ENABLE_WEBHOOKS)
126133
->willReturn(true);
127-
$this->magentoShellMock->expects(self::at(0))
134+
$this->magentoShellMock->expects(self::exactly(2))
128135
->method('execute')
129-
->with('webhooks:generate:module');
130-
$this->magentoShellMock->expects(self::at(1))
131-
->method('execute')
132-
->with('module:enable Magento_AdobeCommerceWebhookPlugins')
133-
->willThrowException(new ShellException('error during module enablement'));
136+
->willReturnCallback(function ($arg1) {
137+
if ($arg1 == 'webhooks:generate:module') {
138+
return $this->processMock;
139+
} elseif ($arg1 == 'module:enable Magento_AdobeCommerceWebhookPlugins') {
140+
throw new ShellException('error during module enablement');
141+
}
142+
});
134143
$this->loggerMock->expects(self::exactly(2))
135144
->method('notice');
136145
$this->loggerMock->expects(self::once())
@@ -149,12 +158,13 @@ public function testExecuteSuccess()
149158
->method('get')
150159
->with(StageConfigInterface::VAR_ENABLE_WEBHOOKS)
151160
->willReturn(true);
152-
$this->magentoShellMock->expects(self::at(0))
153-
->method('execute')
154-
->with('webhooks:generate:module');
155-
$this->magentoShellMock->expects(self::at(1))
161+
$this->magentoShellMock->expects(self::any())
156162
->method('execute')
157-
->with('module:enable Magento_AdobeCommerceWebhookPlugins');
163+
->willReturnCallback(function ($arg1) {
164+
if ($arg1 == 'webhooks:generate:module' || $arg1 == 'module:enable Magento_AdobeCommerceWebhookPlugins') {
165+
return $this->processMock;
166+
}
167+
});
158168
$this->loggerMock->expects(self::exactly(2))
159169
->method('notice');
160170
$this->loggerMock->expects(self::never())

0 commit comments

Comments
 (0)