Skip to content

Commit 88dba11

Browse files
committed
MAGECLOUD-1057: Add possibility to change SCD strategy
1 parent dccd4cf commit 88dba11

File tree

6 files changed

+36
-35
lines changed

6 files changed

+36
-35
lines changed

src/Magento/MagentoCloud/Process/Build/DeployStaticContent/Generate.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Magento\MagentoCloud\Process\ProcessInterface;
1010
use Magento\MagentoCloud\Shell\ShellInterface;
1111
use Magento\MagentoCloud\StaticContent\Build\Option;
12-
use Magento\MagentoCloud\StaticContent\Command;
12+
use Magento\MagentoCloud\StaticContent\CommandFactory;
1313
use Psr\Log\LoggerInterface;
1414

1515
/**
@@ -32,9 +32,9 @@ class Generate implements ProcessInterface
3232
private $environment;
3333

3434
/**
35-
* @var Command
35+
* @var CommandFactory
3636
*/
37-
private $scdCommand;
37+
private $commandFactory;
3838

3939
/**
4040
* @var Option
@@ -45,20 +45,20 @@ class Generate implements ProcessInterface
4545
* @param ShellInterface $shell
4646
* @param LoggerInterface $logger
4747
* @param Environment $environment
48-
* @param Command $scdCommand
48+
* @param CommandFactory $commandFactory
4949
* @param Option $buildOption
5050
*/
5151
public function __construct(
5252
ShellInterface $shell,
5353
LoggerInterface $logger,
5454
Environment $environment,
55-
Command $scdCommand,
55+
CommandFactory $commandFactory,
5656
Option $buildOption
5757
) {
5858
$this->shell = $shell;
5959
$this->logger = $logger;
6060
$this->environment = $environment;
61-
$this->scdCommand = $scdCommand;
61+
$this->commandFactory = $commandFactory;
6262
$this->buildOption = $buildOption;
6363
}
6464

@@ -84,7 +84,7 @@ public function execute()
8484

8585
$this->logger->info($logMessage);
8686

87-
$parallelCommands = $this->scdCommand->createParallel($this->buildOption);
87+
$parallelCommands = $this->commandFactory->createParallel($this->buildOption);
8888

8989
$this->shell->execute(sprintf(
9090
"printf '%s' | xargs -I CMD -P %d bash -c CMD",

src/Magento/MagentoCloud/Process/Deploy/DeployStaticContent/Generate.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Magento\MagentoCloud\Filesystem\Driver\File;
1111
use Magento\MagentoCloud\Process\ProcessInterface;
1212
use Magento\MagentoCloud\Shell\ShellInterface;
13-
use Magento\MagentoCloud\StaticContent\Command;
13+
use Magento\MagentoCloud\StaticContent\CommandFactory;
1414
use Magento\MagentoCloud\StaticContent\Deploy\Option;
1515
use Psr\Log\LoggerInterface;
1616

@@ -45,9 +45,10 @@ class Generate implements ProcessInterface
4545
private $directoryList;
4646

4747
/**
48-
* @var Command
48+
* @var CommandFactory
4949
*/
50-
private $scdCommand;
50+
private $commandFactory;
51+
5152
/**
5253
* @var Option
5354
*/
@@ -59,7 +60,7 @@ class Generate implements ProcessInterface
5960
* @param Environment $environment
6061
* @param File $file
6162
* @param DirectoryList $directoryList
62-
* @param Command $scdCommand
63+
* @param CommandFactory $commandFactory
6364
* @param Option $deployOption
6465
*/
6566
public function __construct(
@@ -68,15 +69,15 @@ public function __construct(
6869
Environment $environment,
6970
File $file,
7071
DirectoryList $directoryList,
71-
Command $scdCommand,
72+
CommandFactory $commandFactory,
7273
Option $deployOption
7374
) {
7475
$this->shell = $shell;
7576
$this->logger = $logger;
7677
$this->environment = $environment;
7778
$this->file = $file;
7879
$this->directoryList = $directoryList;
79-
$this->scdCommand = $scdCommand;
80+
$this->commandFactory = $commandFactory;
8081
$this->deployOption = $deployOption;
8182
}
8283

@@ -96,7 +97,7 @@ public function execute()
9697

9798
$this->logger->info($logMessage);
9899

99-
$command = $this->scdCommand->create($this->deployOption);
100+
$command = $this->commandFactory->create($this->deployOption);
100101

101102
$this->shell->execute($command);
102103

src/Magento/MagentoCloud/StaticContent/Command.php renamed to src/Magento/MagentoCloud/StaticContent/CommandFactory.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/**
99
* Creates static deploy command
1010
*/
11-
class Command
11+
class CommandFactory
1212
{
1313
/**
1414
* Creates static deploy command based on given options
@@ -34,11 +34,11 @@ public function create(OptionInterface $option): string
3434
}
3535

3636
/**
37-
* This method should be removed after replacing xargs with --jobs parameter in build phase
37+
* Creates static deploy command for running in parallel for xargs command
3838
*
3939
* @param OptionInterface $option
4040
* @return string
41-
* @deprecated
41+
* @deprecated This method should be removed after replacing xargs with --jobs parameter in build phase
4242
*/
4343
public function createParallel(OptionInterface $option): string
4444
{

src/Magento/MagentoCloud/Test/Unit/Process/Build/DeployStaticContent/GenerateTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Magento\MagentoCloud\Process\Build\DeployStaticContent\Generate;
1010
use Magento\MagentoCloud\Shell\ShellInterface;
1111
use Magento\MagentoCloud\StaticContent\Build\Option;
12-
use Magento\MagentoCloud\StaticContent\Command;
12+
use Magento\MagentoCloud\StaticContent\CommandFactory;
1313
use PHPUnit\Framework\TestCase;
1414
use PHPUnit_Framework_MockObject_MockObject as Mock;
1515
use Psr\Log\LoggerInterface;
@@ -40,9 +40,9 @@ class GenerateTest extends TestCase
4040
private $environmentMock;
4141

4242
/**
43-
* @var Command|Mock
43+
* @var CommandFactory|Mock
4444
*/
45-
private $commandMock;
45+
private $commandFactoryMock;
4646

4747
/**
4848
* @var Option|Mock
@@ -57,14 +57,14 @@ protected function setUp()
5757
$this->shellMock = $this->getMockForAbstractClass(ShellInterface::class);
5858
$this->loggerMock = $this->getMockForAbstractClass(LoggerInterface::class);
5959
$this->environmentMock = $this->createMock(Environment::class);
60-
$this->commandMock = $this->createMock(Command::class);
60+
$this->commandFactoryMock = $this->createMock(CommandFactory::class);
6161
$this->optionMock = $this->createMock(Option::class);
6262

6363
$this->process = new Generate(
6464
$this->shellMock,
6565
$this->loggerMock,
6666
$this->environmentMock,
67-
$this->commandMock,
67+
$this->commandFactoryMock,
6868
$this->optionMock
6969
);
7070
}
@@ -81,7 +81,7 @@ public function testExecute()
8181
->withConsecutive(
8282
["Generating static content for locales: ua_UA fr_FR es_ES en_US\nUsing 3 Threads"]
8383
);
84-
$this->commandMock->expects($this->once())
84+
$this->commandFactoryMock->expects($this->once())
8585
->method('createParallel')
8686
->with($this->optionMock)
8787
->willReturn('some parallel command');

src/Magento/MagentoCloud/Test/Unit/Process/Deploy/DeployStaticContent/GenerateTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use Magento\MagentoCloud\Process\Deploy\DeployStaticContent\Generate;
1212
use Magento\MagentoCloud\Shell\ShellInterface;
1313
use Magento\MagentoCloud\StaticContent\Deploy\Option;
14-
use Magento\MagentoCloud\StaticContent\Command;
14+
use Magento\MagentoCloud\StaticContent\CommandFactory;
1515
use PHPUnit\Framework\TestCase;
1616
use PHPUnit_Framework_MockObject_MockObject as Mock;
1717
use Psr\Log\LoggerInterface;
@@ -52,9 +52,9 @@ class GenerateTest extends TestCase
5252
private $directoryListMock;
5353

5454
/**
55-
* @var Command|Mock
55+
* @var CommandFactory|Mock
5656
*/
57-
private $commandMock;
57+
private $commandFactoryMock;
5858

5959
/**
6060
* @var Option|Mock
@@ -73,7 +73,7 @@ protected function setUp()
7373
$this->fileMock = $this->createMock(File::class);
7474
$this->directoryListMock = $this->createMock(DirectoryList::class);
7575
$this->environmentMock = $this->createMock(Environment::class);
76-
$this->commandMock = $this->createMock(Command::class);
76+
$this->commandFactoryMock = $this->createMock(CommandFactory::class);
7777
$this->deployOption = $this->createMock(Option::class);
7878

7979
$this->process = new Generate(
@@ -82,7 +82,7 @@ protected function setUp()
8282
$this->environmentMock,
8383
$this->fileMock,
8484
$this->directoryListMock,
85-
$this->commandMock,
85+
$this->commandFactoryMock,
8686
$this->deployOption
8787
);
8888
}
@@ -101,7 +101,7 @@ public function testExecute()
101101
['Generating static content for locales: en_GB fr_FR'],
102102
['Maintenance mode is disabled.']
103103
);
104-
$this->commandMock->expects($this->once())
104+
$this->commandFactoryMock->expects($this->once())
105105
->method('create')
106106
->willReturn('php ./bin/magento static:content:deploy:command');
107107
$this->shellMock->expects($this->exactly(3))

src/Magento/MagentoCloud/Test/Unit/StaticContent/CommandTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@
55
*/
66
namespace Magento\MagentoCloud\Test\Unit\StaticContent;
77

8-
use Magento\MagentoCloud\StaticContent\Command;
8+
use Magento\MagentoCloud\StaticContent\CommandFactory;
99
use Magento\MagentoCloud\StaticContent\OptionInterface;
1010
use PHPUnit\Framework\TestCase;
1111
use PHPUnit_Framework_MockObject_MockObject as Mock;
1212

1313
class CommandTest extends TestCase
1414
{
1515
/**
16-
* @var Command
16+
* @var CommandFactory
1717
*/
18-
private $command;
18+
private $commandFactory;
1919

2020
public function setUp()
2121
{
22-
$this->command = new Command();
22+
$this->commandFactory = new CommandFactory();
2323
}
2424

2525
/**
@@ -31,7 +31,7 @@ public function testCreate(array $optionConfig, $expected)
3131
{
3232
$this->assertEquals(
3333
$expected,
34-
$this->command->create($this->createOption($optionConfig))
34+
$this->commandFactory->create($this->createOption($optionConfig))
3535
);
3636
}
3737

@@ -44,7 +44,7 @@ public function testCreateParallel(array $optionConfig, $expected)
4444
{
4545
$this->assertEquals(
4646
$expected,
47-
$this->command->createParallel($this->createOption($optionConfig))
47+
$this->commandFactory->createParallel($this->createOption($optionConfig))
4848
);
4949
}
5050

0 commit comments

Comments
 (0)