Skip to content

Commit 11343e9

Browse files
authored
MAGECLOUD-5479: Add acceptance function tests for magento-cloud-components (#24)
1 parent 545c235 commit 11343e9

File tree

18 files changed

+265
-8
lines changed

18 files changed

+265
-8
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/.idea
2+
/_workdir
23
/composer.lock
34
/vendor
45
/auth.json

.travis.yml

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,53 @@
1-
dist: trusty
1+
dist: xenial
22

33
git:
44
depth: false
55

6+
addons:
7+
hosts:
8+
- magento2.docker
9+
10+
services:
11+
- docker
12+
613
language: php
714
php:
815
- '7.1'
916
- '7.2'
1017
- '7.3'
1118

1219
env:
13-
- TEST_SUITE=static-unit XDEBUG=true
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.1'
31+
env:
32+
- TEST_SUITE=static-unit
33+
- script: ./tests/travis/static-unit.sh;
34+
php: '7.2'
35+
env:
36+
- TEST_SUITE=static-unit
37+
- script: ./tests/travis/static-unit.sh;
38+
php: '7.3'
39+
env:
40+
- TEST_SUITE=static-unit
1441

1542
install:
43+
- composer config github-oauth.github.com ${GITHUB_TOKEN}
1644
- composer config http-basic.repo.magento.com ${REPO_USERNAME} ${REPO_PASSWORD};
45+
- if [ -n "${MCD_VERSION}" ]; then composer config repositories.mcd git [email protected]:magento/magento-cloud-docker.git && composer require "magento/magento-cloud-docker:${MCD_VERSION}" --no-update; fi;
1746
- composer config repositories.magento composer https://repo.magento.com/
1847
- composer require "magento/framework:*" --no-update
1948
- composer require "magento/module-store:*" --no-update
2049
- composer require "magento/module-url-rewrite:*" --no-update
2150
- composer update -n --no-suggest
2251

2352
script:
24-
- if [ "$TEST_SUITE" == "static-unit" ]; then ./Test/static/static-travis.sh; fi
25-
53+
- if [ $TRAVIS_SECURE_ENV_VARS == "true" ] && [ $TEST_SUITE == "functional" ]; then ./tests/travis/functional.sh; fi;
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\CloudComponents\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\CloudComponents\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\CloudComponents\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('components', '1.0.99');
33+
$I->addArtifactsRepoToComposer();
34+
$I->addEceDockerGitRepoToComposer();
35+
$I->addDependencyToComposer('magento/magento-cloud-components', '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+
}

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: /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
@@ -13,6 +13,8 @@
1313
"magento/module-url-rewrite": "*"
1414
},
1515
"require-dev": {
16+
"codeception/codeception": "^2.5.3",
17+
"consolidation/robo": "^1.2",
1618
"phpmd/phpmd": "@stable",
1719
"phpstan/phpstan": "^0.11",
1820
"phpunit/phpunit": "^6.2",
@@ -36,7 +38,8 @@
3638
"autoload": {
3739
"files": [ "registration.php" ],
3840
"psr-4": {
39-
"Magento\\CloudComponents\\": ""
41+
"Magento\\CloudComponents\\": "",
42+
"Magento\\CloudComponents\\Test\\Functional\\": "tests/functional/"
4043
}
4144
}
4245
}

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)