Skip to content

Commit c876990

Browse files
MAGECLOUD-5478: Add acceptance function tests for magento-cloud-patches (#32)
1 parent 4a385e2 commit c876990

File tree

13 files changed

+281
-6
lines changed

13 files changed

+281
-6
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@
44
/composer.phar
55
/composer.lock
66
/auth.json
7+
/codeception.yml
8+
/_workdir

.travis.yml

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,50 @@ dist: xenial
33
git:
44
depth: false
55

6+
addons:
7+
hosts:
8+
- magento2.docker
9+
10+
services:
11+
- docker
12+
613
language: php
714
php:
8-
- '7.0'
915
- '7.1'
1016
- '7.2'
1117
- '7.3'
1218

13-
install: composer update
19+
env:
20+
- TEST_SUITE=functional
21+
22+
stages:
23+
- static-unit
24+
- test
25+
26+
jobs:
27+
include:
28+
- stage: static-unit
29+
script: ./tests/travis/static-unit.sh;
30+
php: '7.0'
31+
env:
32+
- TEST_SUITE=static-unit
33+
- script: ./tests/travis/static-unit.sh;
34+
php: '7.1'
35+
env:
36+
- TEST_SUITE=static-unit
37+
- script: ./tests/travis/static-unit.sh;
38+
php: '7.2'
39+
env:
40+
- TEST_SUITE=static-unit
41+
- script: ./tests/travis/static-unit.sh;
42+
php: '7.3'
43+
env:
44+
- TEST_SUITE=static-unit
45+
46+
install:
47+
- composer config github-oauth.github.com ${GITHUB_TOKEN}
48+
- if [ -n "${MCD_VERSION}" ] && [ $TRAVIS_PHP_VERSION != "7.0" ]; then composer config repositories.mcd git [email protected]:magento/magento-cloud-docker.git && composer require "magento/magento-cloud-docker:${MCD_VERSION}" --no-update; fi;
49+
- composer update -n --no-suggest
1450

1551
script:
16-
- ./vendor/bin/phpcs ./src --standard=./tests/static/phpcs-ruleset.xml -p -n
17-
- ./vendor/bin/phpmd ./src xml ./tests/static/phpmd-ruleset.xml
18-
- ./vendor/bin/phpunit --configuration ./tests/unit
52+
- if [ $TRAVIS_SECURE_ENV_VARS == "true" ] && [ $TEST_SUITE == "functional" ]; then ./tests/travis/functional.sh; fi;

codeception.dist.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
paths:
2+
tests: src/Test/Functional
3+
output: tests/functional/_output
4+
data: tests/functional/_data
5+
support: vendor/magento/magento-cloud-docker/tests/functional/_support
6+
actor_suffix: Tester
7+
settings:
8+
colors: true
9+
extensions:
10+
enabled:
11+
- Codeception\Extension\RunFailed
12+
- Codeception\Extension\FailedInfo
13+
params:
14+
- vendor/magento/magento-cloud-docker/tests/functional/configuration.dist.yml
15+
- env
16+
modules:
17+
config:
18+
Magento\CloudDocker\Test\Functional\Codeception\TestInfrastructure:
19+
template_repo: "https://github.com/magento/magento-cloud.git"
20+
mcd_repo: "https://github.com/magento/magento-cloud-docker.git"
21+
mcc_repo: "https://github.com/magento/magento-cloud-components.git"
22+
mcp_repo: "https://github.com/magento/magento-cloud-patches.git"
23+
composer_magento_username: "%REPO_USERNAME%"
24+
composer_magento_password: "%REPO_PASSWORD%"
25+
composer_github_token: "%GITHUB_TOKEN%"
26+
printOutput: false
27+
Magento\CloudDocker\Test\Functional\Codeception\Docker:
28+
system_magento_dir: "%Magento.docker.settings.system.magento_dir%"
29+
printOutput: false
30+
PhpBrowser:
31+
url: "%Magento.docker.settings.env.url.base%"
32+
Magento\CloudDocker\Test\Functional\Codeception\MagentoDb:
33+
dsn: "mysql:host=%Magento.docker.settings.db.host%;port=%Magento.docker.settings.db.port%;dbname=%Magento.docker.settings.db.path%"
34+
user: "%Magento.docker.settings.db.username%"
35+
password: "%Magento.docker.settings.db.password%"
36+
exposed_port: "%Magento.docker.settings.db.port%"
37+
reconnect: true

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
"symfony/process": "^2.1||^4.1"
1616
},
1717
"require-dev": {
18+
"codeception/codeception": "^2.5.3",
19+
"consolidation/robo": "^1.2",
1820
"phpmd/phpmd": "@stable",
1921
"phpunit/phpunit": "^6.2",
2022
"squizlabs/php_codesniffer": "^3.0"
@@ -24,7 +26,8 @@
2426
],
2527
"autoload": {
2628
"psr-4": {
27-
"Magento\\CloudPatches\\": "src/"
29+
"Magento\\CloudPatches\\": "src/",
30+
"Magento\\CloudPatches\\Test\\Functional\\": "tests/functional/"
2831
}
2932
},
3033
"scripts": {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
actor: CliTester
2+
modules:
3+
enabled:
4+
- Magento\CloudDocker\Test\Functional\Codeception\TestInfrastructure
5+
- Magento\CloudDocker\Test\Functional\Codeception\Docker
6+
- PhpBrowser
7+
- Asserts
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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 php71
12+
*/
13+
class Acceptance71Cest extends AcceptanceCest
14+
{
15+
/**
16+
* @return array
17+
*/
18+
protected function patchesDataProvider(): array
19+
{
20+
return [
21+
['magentoVersion' => '2.1.16'],
22+
['magentoVersion' => '2.1.18'],
23+
['magentoVersion' => '2.2.0'],
24+
['magentoVersion' => '2.2.11'],
25+
];
26+
}
27+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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 php72
12+
*/
13+
class Acceptance72Cest extends AcceptanceCest
14+
{
15+
/**
16+
* @return array
17+
*/
18+
protected function patchesDataProvider(): array
19+
{
20+
return [
21+
['magentoVersion' => '2.3.0'],
22+
['magentoVersion' => '2.3.2'],
23+
];
24+
}
25+
}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
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 php73
12+
*/
13+
class AcceptanceCest
14+
{
15+
/**
16+
* @param \CliTester $I
17+
*/
18+
public function _before(\CliTester $I): void
19+
{
20+
$I->cleanupWorkDir();
21+
}
22+
23+
/**
24+
* @param \CliTester $I
25+
* @param string $magentoVersion
26+
*/
27+
protected function prepareTemplate(\CliTester $I, string $magentoVersion): void
28+
{
29+
$I->cloneTemplateToWorkDir($magentoVersion);
30+
$I->createAuthJson();
31+
$I->createArtifactsDir();
32+
$I->createArtifactCurrentTestedCode('patches', '1.0.99');
33+
$I->addArtifactsRepoToComposer();
34+
$I->addEceDockerGitRepoToComposer();
35+
$I->addDependencyToComposer('magento/magento-cloud-patches', '1.0.99');
36+
$I->addDependencyToComposer(
37+
'magento/magento-cloud-docker',
38+
$I->getDependencyVersion('magento/magento-cloud-docker')
39+
);
40+
$I->composerUpdate();
41+
}
42+
43+
/**
44+
* @param \CliTester $I
45+
* @param \Codeception\Example $data
46+
* @throws \Robo\Exception\TaskException
47+
* @dataProvider patchesDataProvider
48+
*/
49+
public function testPatches(\CliTester $I, \Codeception\Example $data): void
50+
{
51+
$this->prepareTemplate($I, $data['magentoVersion']);
52+
$this->removeESIfExists($I);
53+
$I->runEceDockerCommand('build:compose --mode=production');
54+
$I->runDockerComposeCommand('run build cloud-build');
55+
$I->startEnvironment();
56+
$I->runDockerComposeCommand('run deploy cloud-deploy');
57+
$I->runDockerComposeCommand('run deploy cloud-post-deploy');
58+
$I->amOnPage('/');
59+
$I->see('Home page');
60+
$I->see('CMS homepage content goes here.');
61+
}
62+
63+
/**
64+
* @param \CliTester $I
65+
*/
66+
protected function removeESIfExists(\CliTester $I): void
67+
{
68+
$services = $I->readServicesYaml();
69+
70+
if (isset($services['elasticsearch'])) {
71+
unset($services['elasticsearch']);
72+
$I->writeServicesYaml($services);
73+
74+
$app = $I->readAppMagentoYaml();
75+
unset($app['relationships']['elasticsearch']);
76+
$I->writeAppMagentoYaml($app);
77+
}
78+
}
79+
80+
/**
81+
* @return array
82+
*/
83+
protected function patchesDataProvider(): array
84+
{
85+
return [
86+
['magentoVersion' => '2.3.3'],
87+
['magentoVersion' => 'master'],
88+
];
89+
}
90+
91+
/**
92+
* @param \CliTester $I
93+
*/
94+
public function _after(\CliTester $I): void
95+
{
96+
$I->stopEnvironment();
97+
$I->removeWorkDir();
98+
}
99+
}

tests/functional/_data/.gitkeep

Whitespace-only changes.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
stage:
2+
global:
3+
MIN_LOGGING_LEVEL: debug
4+
5+
log:
6+
file:
7+
min_level: "debug"
8+
stream:
9+
min_level: "debug"

0 commit comments

Comments
 (0)