Skip to content

Commit dc08373

Browse files
authored
MCLOUD-6455: Increase test coverage for magento-cloud-patches and quality-patches (magento#58)
1 parent db5ca6e commit dc08373

12 files changed

+103
-27
lines changed

.travis.yml

+10
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ jobs:
3939
php: '7.1'
4040
env:
4141
- TEST_SUITE=functional-ee
42+
- PART_INDEX=1
43+
- php: '7.1'
44+
env:
45+
- TEST_SUITE=functional-ee
46+
- PART_INDEX=2
4247
- php: '7.2'
4348
env:
4449
- TEST_SUITE=functional-ee
@@ -48,6 +53,11 @@ jobs:
4853
- php: '7.1'
4954
env:
5055
- TEST_SUITE=functional-ce
56+
- PART_INDEX=1
57+
- php: '7.1'
58+
env:
59+
- TEST_SUITE=functional-ce
60+
- PART_INDEX=2
5161
- php: '7.2'
5262
env:
5363
- TEST_SUITE=functional-ce

codeception.dist.yml

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ modules:
2121
mcc_repo: "https://github.com/magento/magento-cloud-components.git"
2222
mcp_repo: "https://github.com/magento/magento-cloud-patches.git"
2323
mqp_repo: "https://github.com/magento/quality-patches.git"
24+
ece_tools_repo: "https://github.com/magento/ece-tools.git"
2425
composer_magento_username: "%REPO_USERNAME%"
2526
composer_magento_password: "%REPO_PASSWORD%"
2627
composer_github_token: "%GITHUB_TOKEN%"

src/Test/Functional/Acceptance/AbstractCest.php

+22-5
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ public function _before(\CliTester $I): void
2828
/**
2929
* @param \CliTester $I
3030
* @param string $templateVersion
31+
* @param string $magentoVersion
3132
*/
32-
protected function prepareTemplate(\CliTester $I, string $templateVersion): void
33+
protected function prepareTemplate(\CliTester $I, string $templateVersion, string $magentoVersion = null): void
3334
{
3435
$I->cloneTemplateToWorkDir($templateVersion);
3536
$I->createAuthJson();
@@ -38,6 +39,7 @@ protected function prepareTemplate(\CliTester $I, string $templateVersion): void
3839
$I->addArtifactsRepoToComposer();
3940
$I->addEceDockerGitRepoToComposer();
4041
$I->addQualityPatchesGitRepoToComposer();
42+
$I->addEceToolsGitRepoToComposer();
4143
$I->addDependencyToComposer('magento/magento-cloud-patches', '1.0.99');
4244
$I->addDependencyToComposer(
4345
'magento/magento-cloud-docker',
@@ -48,11 +50,15 @@ protected function prepareTemplate(\CliTester $I, string $templateVersion): void
4850
$I->getDependencyVersion('magento/quality-patches')
4951
);
5052

51-
if ($this->edition === 'CE') {
52-
$version = $this->getVersionRangeForMagento($I);
53+
$I->addDependencyToComposer('magento/ece-tools', 'dev-develop as 2002.1.99');
54+
55+
if ($this->edition === 'CE' || $magentoVersion) {
56+
$version = $magentoVersion ?: $this->getVersionRangeForMagento($I);
5357
$I->removeDependencyFromComposer('magento/magento-cloud-metapackage');
54-
$I->addDependencyToComposer('magento/ece-tools', '^2002.1.0');
55-
$I->addDependencyToComposer('magento/product-community-edition', $version);
58+
$I->addDependencyToComposer(
59+
$this->edition === 'CE' ? 'magento/product-community-edition' : 'magento/product-enterprise-edition',
60+
$version
61+
);
5662
}
5763

5864
$I->composerUpdate();
@@ -67,6 +73,17 @@ protected function convertEnvFromArrayToJson(array $data): string
6773
return addslashes(json_encode($data));
6874
}
6975

76+
/**
77+
* @param \CliTester $I
78+
* @return string
79+
*/
80+
protected function getVersionRangeForMagento(\CliTester $I): string
81+
{
82+
$composer = json_decode(file_get_contents($I->getWorkDirPath() . '/composer.json'), true);
83+
84+
return $composer['require']['magento/magento-cloud-metapackage'] ?? '';
85+
}
86+
7087
/**
7188
* @param \CliTester $I
7289
*/

src/Test/Functional/Acceptance/Acceptance71CeCest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace Magento\CloudPatches\Test\Functional\Acceptance;
99

1010
/**
11-
* @group php71ce
11+
* @group php71cePart1
1212
*/
1313
class Acceptance71CeCest extends Acceptance71Cest
1414
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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\CloudPatches\Test\Functional\Acceptance;
9+
10+
/**
11+
* @group php71cePart2
12+
*/
13+
class Acceptance71CePart2Cest extends Acceptance71Part2Cest
14+
{
15+
/**
16+
* @var string
17+
*/
18+
protected $edition = 'CE';
19+
}

src/Test/Functional/Acceptance/Acceptance71Cest.php

+1-9
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace Magento\CloudPatches\Test\Functional\Acceptance;
99

1010
/**
11-
* @group php71
11+
* @group php71Part1
1212
*/
1313
class Acceptance71Cest extends AcceptanceCest
1414
{
@@ -25,14 +25,6 @@ protected function patchesDataProvider(): array
2525
['templateVersion' => '2.2.1'],
2626
['templateVersion' => '2.2.2'],
2727
['templateVersion' => '2.2.3'],
28-
['templateVersion' => '2.2.4'],
29-
['templateVersion' => '2.2.5'],
30-
['templateVersion' => '2.2.6'],
31-
['templateVersion' => '2.2.7'],
32-
['templateVersion' => '2.2.8'],
33-
['templateVersion' => '2.2.9'],
34-
['templateVersion' => '2.2.10'],
35-
['templateVersion' => '2.2.11'],
3628
];
3729
}
3830
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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\CloudPatches\Test\Functional\Acceptance;
9+
10+
/**
11+
* @group php71Part2
12+
*/
13+
class Acceptance71Part2Cest extends AcceptanceCest
14+
{
15+
/**
16+
* @return array
17+
*/
18+
protected function patchesDataProvider(): array
19+
{
20+
return [
21+
['templateVersion' => '2.2.4'],
22+
['templateVersion' => '2.2.5'],
23+
['templateVersion' => '2.2.6'],
24+
['templateVersion' => '2.2.7'],
25+
['templateVersion' => '2.2.8'],
26+
['templateVersion' => '2.2.9'],
27+
['templateVersion' => '2.2.10'],
28+
['templateVersion' => '2.2.11'],
29+
];
30+
}
31+
}

src/Test/Functional/Acceptance/Acceptance72Cest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ protected function patchesDataProvider(): array
2020
return [
2121
['templateVersion' => '2.3.0'],
2222
['templateVersion' => '2.3.1'],
23-
['templateVersion' => '2.3.2'],
23+
['templateVersion' => '2.3.2', 'magentoVersion' => '2.3.2'],
24+
['templateVersion' => '2.3.2', 'magentoVersion' => '2.3.2-p2'],
2425
];
2526
}
2627
}

src/Test/Functional/Acceptance/AcceptanceCest.php

+10-9
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,10 @@ class AcceptanceCest extends AbstractCest
1414
{
1515
/**
1616
* @param \CliTester $I
17-
* @return string
1817
*/
19-
protected function getVersionRangeForMagento(\CliTester $I): string
18+
public function _before(\CliTester $I): void
2019
{
21-
$composer = json_decode(file_get_contents($I->getWorkDirPath() . '/composer.json'), true);
22-
23-
return $composer['require']['magento/magento-cloud-metapackage'] ?? '';
20+
parent::_before($I);
2421
}
2522

2623
/**
@@ -31,7 +28,8 @@ protected function getVersionRangeForMagento(\CliTester $I): string
3128
*/
3229
public function testPatches(\CliTester $I, \Codeception\Example $data): void
3330
{
34-
$this->prepareTemplate($I, $data['templateVersion']);
31+
$this->prepareTemplate($I, $data['templateVersion'], $data['magentoVersion'] ?? null);
32+
$I->copyFileToWorkDir('files/patches/.apply_quality_patches.env.yaml', '.magento.env.yaml');
3533
$I->runEceDockerCommand(sprintf(
3634
'build:compose --mode=production --env-vars="%s"',
3735
$this->convertEnvFromArrayToJson(['MAGENTO_CLOUD_PROJECT' => 'travis-testing'])
@@ -51,9 +49,12 @@ public function testPatches(\CliTester $I, \Codeception\Example $data): void
5149
protected function patchesDataProvider(): array
5250
{
5351
return [
54-
['templateVersion' => '2.3.3'],
55-
['templateVersion' => '2.3.4'],
56-
['templateVersion' => '2.3.5'],
52+
['templateVersion' => '2.3.3', 'magentoVersion' => '2.3.3'],
53+
['templateVersion' => '2.3.3', 'magentoVersion' => '2.3.3-p1'],
54+
['templateVersion' => '2.3.4', 'magentoVersion' => '2.3.4'],
55+
['templateVersion' => '2.3.4', 'magentoVersion' => '2.3.4-p2'],
56+
['templateVersion' => '2.3.5', 'magentoVersion' => '2.3.5'],
57+
['templateVersion' => '2.3.5', 'magentoVersion' => '2.3.5-p1'],
5758
['templateVersion' => 'master'],
5859
];
5960
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
stage:
2+
build:
3+
QUALITY_PATCHES:
4+
- '*'

tests/travis/functional-ce.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ trap '>&2 echo Error: Command \`$BASH_COMMAND\` on line $LINENO failed with exit
88

99
case $TRAVIS_PHP_VERSION in
1010
7.1)
11-
./vendor/bin/codecept run -g php71ce --steps
11+
./vendor/bin/codecept run -g php71cePart$PART_INDEX --steps
1212
;;
1313
7.2)
1414
./vendor/bin/codecept run -g php72ce --steps

tests/travis/functional-ee.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ trap '>&2 echo Error: Command \`$BASH_COMMAND\` on line $LINENO failed with exit
88

99
case $TRAVIS_PHP_VERSION in
1010
7.1)
11-
./vendor/bin/codecept run -g php71 --steps
11+
./vendor/bin/codecept run -g php71cePart$PART_INDEX --steps
1212
;;
1313
7.2)
1414
./vendor/bin/codecept run -g php72 --steps

0 commit comments

Comments
 (0)