Skip to content

Commit 86043d4

Browse files
committed
MC-42026: [Cloud] Custom theme is not applied and the default LUMA theme is used.
1 parent 97e96a8 commit 86043d4

File tree

2 files changed

+117
-35
lines changed

2 files changed

+117
-35
lines changed

app/code/Magento/Deploy/Process/Queue.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public function getPackages()
167167
* Process jobs
168168
*
169169
* @return int
170-
* @throws TimeoutException
170+
* @throws \RuntimeException
171171
*/
172172
public function process()
173173
{
@@ -291,6 +291,7 @@ private function awaitForAllProcesses()
291291

292292
if ($isDeployed === false) {
293293
$this->failed[$package->getPath()]= $this->packages[$package->getPath()];
294+
unset($this->inProgress[$name]);
294295
} elseif ($isDeployed) {
295296
unset($this->inProgress[$name]);
296297
}

app/code/Magento/Deploy/Test/Unit/Process/QueueTest.php

Lines changed: 115 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,16 @@
88
namespace Magento\Deploy\Test\Unit\Process;
99

1010
use Magento\Deploy\Package\Package;
11+
use Magento\Deploy\Package\PackageFile;
1112
use Magento\Deploy\Process\Queue;
1213
use Magento\Deploy\Service\DeployPackage;
14+
use Magento\Deploy\Service\DeployStaticFile;
1315
use Magento\Framework\App\ResourceConnection;
14-
1516
use Magento\Framework\App\State as AppState;
17+
use Magento\Framework\Config\ScopeInterface;
1618
use Magento\Framework\Locale\ResolverInterface as LocaleResolver;
1719
use PHPUnit\Framework\MockObject\MockObject as Mock;
1820
use PHPUnit\Framework\TestCase;
19-
2021
use Psr\Log\LoggerInterface;
2122

2223
/**
@@ -27,12 +28,7 @@
2728
class QueueTest extends TestCase
2829
{
2930
/**
30-
* @var Queue
31-
*/
32-
private $queue;
33-
34-
/**
35-
* @var AppState|Mock
31+
* @var AppState
3632
*/
3733
private $appState;
3834

@@ -52,39 +48,64 @@ class QueueTest extends TestCase
5248
private $logger;
5349

5450
/**
55-
* @var DeployPackage|Mock
51+
* @var DeployPackage
5652
*/
5753
private $deployPackageService;
5854

55+
/**
56+
* @var DeployStaticFile|Mock
57+
*/
58+
private $deployStaticFile;
59+
60+
/**
61+
* @var Package|Mock
62+
*/
63+
private $package;
64+
65+
/**
66+
* @var PackageFile|Mock
67+
*/
68+
private $packageFile;
69+
5970
/**
6071
* @inheritdoc
6172
*/
6273
protected function setUp(): void
6374
{
64-
$this->appState = $this->createMock(AppState::class);
75+
$this->resourceConnection = $this->createMock(ResourceConnection::class);
76+
$this->package = $this->createMock(Package::class);
77+
$this->deployStaticFile = $this->createMock(DeployStaticFile::class);
78+
79+
$this->packageFile = $this->createMock(PackageFile::class);
80+
$this->packageFile
81+
->expects($this->any())
82+
->method('getContent')
83+
->willReturn('{}');
84+
6585
$this->localeResolver = $this->getMockForAbstractClass(
6686
LocaleResolver::class,
6787
['setLocale'],
6888
'',
6989
false
7090
);
71-
$this->resourceConnection = $this->createMock(ResourceConnection::class);
91+
7292
$this->logger = $this->getMockForAbstractClass(
7393
LoggerInterface::class,
7494
['notice', 'info'],
7595
'',
7696
false
7797
);
78-
$this->deployPackageService = $this->createPartialMock(DeployPackage::class, ['deploy']);
7998

80-
$this->queue = new Queue(
99+
$configScope = $this->createMock(ScopeInterface::class);
100+
$this->appState = new AppState(
101+
$configScope
102+
);
103+
104+
$this->deployPackageService = new DeployPackage(
81105
$this->appState,
82106
$this->localeResolver,
83-
$this->resourceConnection,
84-
$this->logger,
85-
$this->deployPackageService,
86-
[],
87-
1
107+
$this->deployStaticFile,
108+
$this->logger
88109
);
89110
}
90111

@@ -93,13 +114,21 @@ protected function setUp(): void
93114
*/
94115
public function testAdd()
95116
{
96-
$package = $this->createMock(Package::class);
97-
$package->expects($this->once())->method('getPath')->willReturn('path');
117+
$queue = new Queue(
118+
$this->appState,
119+
$this->localeResolver,
120+
$this->resourceConnection,
121+
$this->logger,
122+
$this->deployPackageService,
123+
[],
124+
0
125+
);
98126

99-
$this->assertTrue($this->queue->add($package));
100-
$packages = $this->queue->getPackages();
127+
$this->package->expects($this->once())->method('getPath')->willReturn('path');
128+
$this->assertTrue($queue->add($this->package));
129+
$packages = $queue->getPackages();
101130
$this->assertEquals(
102-
$package,
131+
$this->package,
103132
isset($packages['path']['package']) ? $packages['path']['package'] : null
104133
);
105134
}
@@ -109,20 +138,72 @@ public function testAdd()
109138
*/
110139
public function testProcess()
111140
{
112-
$package = $this->createMock(Package::class);
113-
$package->expects($this->any())->method('getState')->willReturn(0);
114-
$package->expects($this->exactly(2))->method('getParent')->willReturn(true);
115-
$package->expects($this->any())->method('getArea')->willReturn('area');
116-
$package->expects($this->any())->method('getPath')->willReturn('path');
117-
$package->expects($this->any())->method('getFiles')->willReturn([]);
118-
$this->logger->expects($this->exactly(2))->method('info')->willReturnSelf();
141+
$queue = new Queue(
142+
$this->appState,
143+
$this->localeResolver,
144+
$this->resourceConnection,
145+
$this->logger,
146+
$this->deployPackageService,
147+
[],
148+
0
149+
);
119150

120-
$this->appState->expects($this->once())->method('emulateAreaCode');
151+
$this->package->expects($this->any())->method('getState')->willReturn(0);
152+
$this->package->expects($this->exactly(2))->method('getParent')->willReturn(true);
153+
$this->package->expects($this->any())->method('getArea')->willReturn('global');
154+
$this->package->expects($this->any())->method('getPath')->willReturn('path');
155+
$this->package->expects($this->any())->method('getFiles')->willReturn([]);
156+
$this->package->expects($this->any())->method('getPreProcessors')->willReturn([]);
157+
$this->package->expects($this->any())->method('getPostProcessors')->willReturn([]);
158+
$this->logger->expects($this->exactly(3))->method('info')->willReturnSelf();
159+
$queue->add($this->package, []);
160+
$this->resourceConnection->expects(self::never())->method('closeConnection');
161+
$this->assertEquals(0, $queue->process());
162+
}
121163

122-
$this->queue->add($package, []);
164+
/**
165+
* @see Queue::process()
166+
* @dataProvider maxProcessesDataProvider
167+
*/
168+
public function testProcessFailedPackagesToThrowAnException($maxProcesses)
169+
{
170+
$this->deployStaticFile
171+
->expects($this->any())
172+
->method('writeFile')
173+
->willThrowException(new \Exception);
123174

124-
$this->resourceConnection->expects(self::never())->method('closeConnection');
175+
$queue = new Queue(
176+
$this->appState,
177+
$this->localeResolver,
178+
$this->resourceConnection,
179+
$this->logger,
180+
$this->deployPackageService,
181+
[],
182+
$maxProcesses
183+
);
125184

126-
$this->assertEquals(0, $this->queue->process());
185+
$this->package->expects($this->any())->method('getState')->willReturn(0);
186+
$this->package->expects($this->any())->method('getParent')->willReturn(true);
187+
$this->package->expects($this->any())->method('getArea')->willReturn('global');
188+
$this->package->expects($this->any())->method('getPath')->willReturn('path');
189+
$this->package->expects($this->any())->method('getFiles')->willReturn([$this->packageFile]);
190+
$this->package->expects($this->any())->method('getPreProcessors')->willReturn([]);
191+
$this->package->expects($this->any())->method('getPostProcessors')->willReturn([]);
192+
$this->logger->expects($this->any())->method('info')->willReturnSelf();
193+
$queue->add($this->package, []);
194+
$this->expectException(\RuntimeException::class);
195+
$queue->process();
127196
}
197+
198+
/**
199+
* @return int[]
200+
*/
201+
public function maxProcessesDataProvider(): array
202+
{
203+
return [
204+
[0],
205+
[1]
206+
];
207+
}
208+
128209
}

0 commit comments

Comments
 (0)