Skip to content

Commit f1e6f7f

Browse files
authored
Merge pull request #12 from magento-commerce/MCLOUD-7193
2 parents d40c3e7 + 35540f5 commit f1e6f7f

File tree

2 files changed

+30
-18
lines changed

2 files changed

+30
-18
lines changed

src/Config/Validator/Deploy/ServiceVersion.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ public function validate(): Validator\ResultInterface
7171
$services = [
7272
ServiceInterface::NAME_RABBITMQ,
7373
ServiceInterface::NAME_REDIS,
74-
ServiceInterface::NAME_DB
74+
ServiceInterface::NAME_DB,
75+
ServiceInterface::NAME_ELASTICSEARCH
7576
];
7677

7778
$errors = [];

src/Test/Unit/Config/Validator/Deploy/ServiceVersionTest.php

+28-17
Original file line numberDiff line numberDiff line change
@@ -72,33 +72,39 @@ protected function setUp()
7272

7373
public function testValidate(): void
7474
{
75-
$service1 = $this->createMock(ServiceInterface::class);
76-
$service1->expects($this->once())
75+
$serviceRmq = $this->createMock(ServiceInterface::class);
76+
$serviceRmq->expects($this->once())
7777
->method('getVersion')
7878
->willReturn('0');
79-
$service2 = $this->createMock(ServiceInterface::class);
80-
$service2->expects($this->once())
79+
$serviceRedis = $this->createMock(ServiceInterface::class);
80+
$serviceRedis->expects($this->once())
8181
->method('getVersion')
8282
->willReturn('3.2');
83-
$service3 = $this->createMock(ServiceInterface::class);
84-
$service3->expects($this->once())
83+
$serviceDB = $this->createMock(ServiceInterface::class);
84+
$serviceDB->expects($this->once())
8585
->method('getVersion')
8686
->willReturn('10.2');
87-
$this->serviceFactory->expects($this->exactly(3))
87+
$serviceES = $this->createMock(ServiceInterface::class);
88+
$serviceES->expects($this->once())
89+
->method('getVersion')
90+
->willReturn('7.7');
91+
$this->serviceFactory->expects($this->exactly(4))
8892
->method('create')
89-
->willReturnOnConsecutiveCalls($service1, $service2, $service3);
90-
$this->loggerMock->expects($this->exactly(3))
93+
->willReturnOnConsecutiveCalls($serviceRmq, $serviceRedis, $serviceDB, $serviceES);
94+
$this->loggerMock->expects($this->exactly(4))
9195
->method('info')
9296
->withConsecutive(
9397
['Version of service \'rabbitmq\' is not detected', []],
9498
['Version of service \'redis\' is 3.2', []],
95-
['Version of service \'mysql\' is 10.2', []]
99+
['Version of service \'mysql\' is 10.2', []],
100+
['Version of service \'elasticsearch\' is 7.7', []]
96101
);
97-
$this->serviceVersionValidatorMock->expects($this->exactly(2))
102+
$this->serviceVersionValidatorMock->expects($this->exactly(3))
98103
->method('validateService')
99104
->withConsecutive(
100105
[ServiceInterface::NAME_REDIS, '3.2'],
101-
[ServiceInterface::NAME_DB, '10.2']
106+
[ServiceInterface::NAME_DB, '10.2'],
107+
[ServiceInterface::NAME_ELASTICSEARCH, '7.7']
102108
)
103109
->willReturn('');
104110
$this->resultFactoryMock->expects($this->once())
@@ -109,7 +115,7 @@ public function testValidate(): void
109115

110116
public function testValidateWithErrors(): void
111117
{
112-
$errorMessages = ['error message 1', 'error message 2', 'error message 3'];
118+
$errorMessages = ['error message 1', 'error message 2', 'error message 3', 'error message 4'];
113119
$service1 = $this->createMock(ServiceInterface::class);
114120
$service1->expects($this->once())
115121
->method('getVersion')
@@ -122,15 +128,20 @@ public function testValidateWithErrors(): void
122128
$service3->expects($this->once())
123129
->method('getVersion')
124130
->willReturn('5.7');
125-
$this->serviceFactory->expects($this->exactly(3))
131+
$service4 = $this->createMock(ServiceInterface::class);
132+
$service4->expects($this->once())
133+
->method('getVersion')
134+
->willReturn('7.7');
135+
$this->serviceFactory->expects($this->exactly(4))
126136
->method('create')
127-
->willReturnOnConsecutiveCalls($service1, $service2, $service3);
128-
$this->serviceVersionValidatorMock->expects($this->exactly(3))
137+
->willReturnOnConsecutiveCalls($service1, $service2, $service3, $service4);
138+
$this->serviceVersionValidatorMock->expects($this->exactly(4))
129139
->method('validateService')
130140
->withConsecutive(
131141
[ServiceInterface::NAME_RABBITMQ, '1.5'],
132142
[ServiceInterface::NAME_REDIS, '2.2'],
133-
[ServiceInterface::NAME_DB, '5.7']
143+
[ServiceInterface::NAME_DB, '5.7'],
144+
[ServiceInterface::NAME_ELASTICSEARCH, '7.7']
134145
)
135146
->willReturnOnConsecutiveCalls(...$errorMessages);
136147
$this->resultFactoryMock->expects($this->once())

0 commit comments

Comments
 (0)