Skip to content

Commit 4644333

Browse files
committed
ACP2E-1168: Static content deployment timed out or failed
1 parent 91ad6b0 commit 4644333

File tree

1 file changed

+109
-0
lines changed
  • app/code/Magento/Deploy/Test/Unit/Package/Processor/PreProcessor

1 file changed

+109
-0
lines changed
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Deploy\Test\Unit\Package\Processor\PreProcessor;
9+
10+
use Magento\Deploy\Console\DeployStaticOptions;
11+
use Magento\Deploy\Package\Processor\PreProcessor\Css;
12+
use Magento\Deploy\Package\Package;
13+
use Magento\Deploy\Package\PackageFile;
14+
use Magento\Framework\View\Asset\Minification;
15+
use Magento\Framework\Filesystem;
16+
use Magento\Framework\Filesystem\Directory\ReadInterface;
17+
use PHPUnit\Framework\MockObject\MockObject;
18+
use PHPUnit\Framework\TestCase;
19+
20+
class CssTest extends TestCase
21+
{
22+
/**
23+
* @var Filesystem|MockObject
24+
*/
25+
private $filesystem;
26+
27+
/**
28+
* @var Minification|MockObject
29+
*/
30+
private $minification;
31+
32+
/**
33+
* @var ReadInterface|MockObject
34+
*/
35+
private $staticDir;
36+
37+
/**
38+
* @var Package|MockObject
39+
*/
40+
private $package;
41+
42+
/**
43+
* @var PackageFile|MockObject
44+
*/
45+
private $file;
46+
47+
/**
48+
* @var Css
49+
*/
50+
private $model;
51+
52+
/**
53+
* @inheritdoc
54+
*/
55+
protected function setUp(): void
56+
{
57+
$this->filesystem = $this->getMockBuilder(Filesystem::class)
58+
->disableOriginalConstructor()
59+
->getMock();
60+
$this->minification = $this->getMockBuilder(Minification::class)
61+
->disableOriginalConstructor()
62+
->getMock();
63+
$this->staticDir = $this->getMockBuilder(ReadInterface::class)
64+
->getMockForAbstractClass();
65+
$this->filesystem->expects($this->any())
66+
->method('getDirectoryRead')
67+
->willReturn($this->staticDir);
68+
$this->package = $this->getMockBuilder(Package::class)
69+
->disableOriginalConstructor()
70+
->getMock();
71+
$this->file = $this->getMockBuilder(PackageFile::class)
72+
->disableOriginalConstructor()
73+
->getMock();
74+
75+
$this->model = new Css($this->filesystem, $this->minification);
76+
}
77+
78+
public function testProcessWithNonExistingFile(): void
79+
{
80+
$options = [
81+
DeployStaticOptions::NO_CSS => false
82+
];
83+
$nonReadableFile = 'nonReadableFile';
84+
85+
$this->package->expects($this->once())
86+
->method('getParentFiles')
87+
->with('css')
88+
->willReturn([$this->file]);
89+
$this->file->expects($this->once())
90+
->method('getPackage')
91+
->willReturn($this->package);
92+
$this->file->expects($this->any())
93+
->method('getDeployedFilePath')
94+
->willReturn('some/path/to/file');
95+
$this->package->expects($this->any())
96+
->method('getFiles')
97+
->willReturn([]);
98+
$this->minification->expects($this->once())
99+
->method('addMinifiedSign')
100+
->willReturn($nonReadableFile);
101+
$this->staticDir->expects($this->once())
102+
->method('isReadable')
103+
->with($nonReadableFile)
104+
->willReturn(false);
105+
$this->staticDir->expects($this->never())
106+
->method('readFile');
107+
$this->model->process($this->package, $options);
108+
}
109+
}

0 commit comments

Comments
 (0)