Skip to content

MCLOUD-6455: Increase test coverage for magento-cloud-patches and quality-patches #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ jobs:
php: '7.1'
env:
- TEST_SUITE=functional-ee
- PART_INDEX=1
- php: '7.1'
env:
- TEST_SUITE=functional-ee
- PART_INDEX=2
- php: '7.2'
env:
- TEST_SUITE=functional-ee
Expand All @@ -48,6 +53,11 @@ jobs:
- php: '7.1'
env:
- TEST_SUITE=functional-ce
- PART_INDEX=1
- php: '7.1'
env:
- TEST_SUITE=functional-ce
- PART_INDEX=2
- php: '7.2'
env:
- TEST_SUITE=functional-ce
Expand Down
1 change: 1 addition & 0 deletions codeception.dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ modules:
mcc_repo: "https://github.com/magento/magento-cloud-components.git"
mcp_repo: "https://github.com/magento/magento-cloud-patches.git"
mqp_repo: "https://github.com/magento/quality-patches.git"
ece_tools_repo: "https://github.com/magento/ece-tools.git"
composer_magento_username: "%REPO_USERNAME%"
composer_magento_password: "%REPO_PASSWORD%"
composer_github_token: "%GITHUB_TOKEN%"
Expand Down
27 changes: 22 additions & 5 deletions src/Test/Functional/Acceptance/AbstractCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ public function _before(\CliTester $I): void
/**
* @param \CliTester $I
* @param string $templateVersion
* @param string $magentoVersion
*/
protected function prepareTemplate(\CliTester $I, string $templateVersion): void
protected function prepareTemplate(\CliTester $I, string $templateVersion, string $magentoVersion = null): void
{
$I->cloneTemplateToWorkDir($templateVersion);
$I->createAuthJson();
Expand All @@ -38,6 +39,7 @@ protected function prepareTemplate(\CliTester $I, string $templateVersion): void
$I->addArtifactsRepoToComposer();
$I->addEceDockerGitRepoToComposer();
$I->addQualityPatchesGitRepoToComposer();
$I->addEceToolsGitRepoToComposer();
$I->addDependencyToComposer('magento/magento-cloud-patches', '1.0.99');
$I->addDependencyToComposer(
'magento/magento-cloud-docker',
Expand All @@ -48,11 +50,15 @@ protected function prepareTemplate(\CliTester $I, string $templateVersion): void
$I->getDependencyVersion('magento/quality-patches')
);

if ($this->edition === 'CE') {
$version = $this->getVersionRangeForMagento($I);
$I->addDependencyToComposer('magento/ece-tools', 'dev-develop as 2002.1.99');

if ($this->edition === 'CE' || $magentoVersion) {
$version = $magentoVersion ?: $this->getVersionRangeForMagento($I);
$I->removeDependencyFromComposer('magento/magento-cloud-metapackage');
$I->addDependencyToComposer('magento/ece-tools', '^2002.1.0');
$I->addDependencyToComposer('magento/product-community-edition', $version);
$I->addDependencyToComposer(
$this->edition === 'CE' ? 'magento/product-community-edition' : 'magento/product-enterprise-edition',
$version
);
}

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

/**
* @param \CliTester $I
* @return string
*/
protected function getVersionRangeForMagento(\CliTester $I): string
{
$composer = json_decode(file_get_contents($I->getWorkDirPath() . '/composer.json'), true);

return $composer['require']['magento/magento-cloud-metapackage'] ?? '';
}

/**
* @param \CliTester $I
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Test/Functional/Acceptance/Acceptance71CeCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace Magento\CloudPatches\Test\Functional\Acceptance;

/**
* @group php71ce
* @group php71cePart1
*/
class Acceptance71CeCest extends Acceptance71Cest
{
Expand Down
19 changes: 19 additions & 0 deletions src/Test/Functional/Acceptance/Acceptance71CePart2Cest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\CloudPatches\Test\Functional\Acceptance;

/**
* @group php71cePart2
*/
class Acceptance71CePart2Cest extends Acceptance71Part2Cest
{
/**
* @var string
*/
protected $edition = 'CE';
}
10 changes: 1 addition & 9 deletions src/Test/Functional/Acceptance/Acceptance71Cest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace Magento\CloudPatches\Test\Functional\Acceptance;

/**
* @group php71
* @group php71Part1
*/
class Acceptance71Cest extends AcceptanceCest
{
Expand All @@ -25,14 +25,6 @@ protected function patchesDataProvider(): array
['templateVersion' => '2.2.1'],
['templateVersion' => '2.2.2'],
['templateVersion' => '2.2.3'],
['templateVersion' => '2.2.4'],
['templateVersion' => '2.2.5'],
['templateVersion' => '2.2.6'],
['templateVersion' => '2.2.7'],
['templateVersion' => '2.2.8'],
['templateVersion' => '2.2.9'],
['templateVersion' => '2.2.10'],
['templateVersion' => '2.2.11'],
];
}
}
31 changes: 31 additions & 0 deletions src/Test/Functional/Acceptance/Acceptance71Part2Cest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\CloudPatches\Test\Functional\Acceptance;

/**
* @group php71Part2
*/
class Acceptance71Part2Cest extends AcceptanceCest
{
/**
* @return array
*/
protected function patchesDataProvider(): array
{
return [
['templateVersion' => '2.2.4'],
['templateVersion' => '2.2.5'],
['templateVersion' => '2.2.6'],
['templateVersion' => '2.2.7'],
['templateVersion' => '2.2.8'],
['templateVersion' => '2.2.9'],
['templateVersion' => '2.2.10'],
['templateVersion' => '2.2.11'],
];
}
}
3 changes: 2 additions & 1 deletion src/Test/Functional/Acceptance/Acceptance72Cest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ protected function patchesDataProvider(): array
return [
['templateVersion' => '2.3.0'],
['templateVersion' => '2.3.1'],
['templateVersion' => '2.3.2'],
['templateVersion' => '2.3.2', 'magentoVersion' => '2.3.2'],
['templateVersion' => '2.3.2', 'magentoVersion' => '2.3.2-p2'],
];
}
}
19 changes: 10 additions & 9 deletions src/Test/Functional/Acceptance/AcceptanceCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,10 @@ class AcceptanceCest extends AbstractCest
{
/**
* @param \CliTester $I
* @return string
*/
protected function getVersionRangeForMagento(\CliTester $I): string
public function _before(\CliTester $I): void
{
$composer = json_decode(file_get_contents($I->getWorkDirPath() . '/composer.json'), true);

return $composer['require']['magento/magento-cloud-metapackage'] ?? '';
parent::_before($I);
}

/**
Expand All @@ -31,7 +28,8 @@ protected function getVersionRangeForMagento(\CliTester $I): string
*/
public function testPatches(\CliTester $I, \Codeception\Example $data): void
{
$this->prepareTemplate($I, $data['templateVersion']);
$this->prepareTemplate($I, $data['templateVersion'], $data['magentoVersion'] ?? null);
$I->copyFileToWorkDir('files/patches/.apply_quality_patches.env.yaml', '.magento.env.yaml');
$I->runEceDockerCommand(sprintf(
'build:compose --mode=production --env-vars="%s"',
$this->convertEnvFromArrayToJson(['MAGENTO_CLOUD_PROJECT' => 'travis-testing'])
Expand All @@ -51,9 +49,12 @@ public function testPatches(\CliTester $I, \Codeception\Example $data): void
protected function patchesDataProvider(): array
{
return [
['templateVersion' => '2.3.3'],
['templateVersion' => '2.3.4'],
['templateVersion' => '2.3.5'],
['templateVersion' => '2.3.3', 'magentoVersion' => '2.3.3'],
['templateVersion' => '2.3.3', 'magentoVersion' => '2.3.3-p1'],
['templateVersion' => '2.3.4', 'magentoVersion' => '2.3.4'],
['templateVersion' => '2.3.4', 'magentoVersion' => '2.3.4-p2'],
['templateVersion' => '2.3.5', 'magentoVersion' => '2.3.5'],
['templateVersion' => '2.3.5', 'magentoVersion' => '2.3.5-p1'],
['templateVersion' => 'master'],
];
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
stage:
build:
QUALITY_PATCHES:
- '*'
2 changes: 1 addition & 1 deletion tests/travis/functional-ce.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ trap '>&2 echo Error: Command \`$BASH_COMMAND\` on line $LINENO failed with exit

case $TRAVIS_PHP_VERSION in
7.1)
./vendor/bin/codecept run -g php71ce --steps
./vendor/bin/codecept run -g php71cePart$PART_INDEX --steps
;;
7.2)
./vendor/bin/codecept run -g php72ce --steps
Expand Down
2 changes: 1 addition & 1 deletion tests/travis/functional-ee.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ trap '>&2 echo Error: Command \`$BASH_COMMAND\` on line $LINENO failed with exit

case $TRAVIS_PHP_VERSION in
7.1)
./vendor/bin/codecept run -g php71 --steps
./vendor/bin/codecept run -g php71cePart$PART_INDEX --steps
;;
7.2)
./vendor/bin/codecept run -g php72 --steps
Expand Down