Skip to content
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
/composer.phar
/composer.lock
/auth.json
/codeception.yml
/_workdir
44 changes: 39 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,50 @@ dist: xenial
git:
depth: false

addons:
hosts:
- magento2.docker

services:
- docker

language: php
php:
- '7.0'
- '7.1'
- '7.2'
- '7.3'

install: composer update
env:
- TEST_SUITE=functional

stages:
- static-unit
- test

jobs:
include:
- stage: static-unit
script: ./tests/travis/static-unit.sh;
php: '7.0'
env:
- TEST_SUITE=static-unit
- script: ./tests/travis/static-unit.sh;
php: '7.1'
env:
- TEST_SUITE=static-unit
- script: ./tests/travis/static-unit.sh;
php: '7.2'
env:
- TEST_SUITE=static-unit
- script: ./tests/travis/static-unit.sh;
php: '7.3'
env:
- TEST_SUITE=static-unit

install:
- composer config github-oauth.github.com ${GITHUB_TOKEN}
- if [ -n "${MCD_VERSION}" ] && [ $TRAVIS_PHP_VERSION != "7.0" ]; then composer config repositories.mcd git git@github.com:magento/magento-cloud-docker.git && composer require "magento/magento-cloud-docker:${MCD_VERSION}" --no-update; fi;
- composer update -n --no-suggest

script:
- ./vendor/bin/phpcs ./src --standard=./tests/static/phpcs-ruleset.xml -p -n
- ./vendor/bin/phpmd ./src xml ./tests/static/phpmd-ruleset.xml
- ./vendor/bin/phpunit --configuration ./tests/unit
- if [ $TRAVIS_SECURE_ENV_VARS == "true" ] && [ $TEST_SUITE == "functional" ]; then ./tests/travis/functional.sh; fi;
37 changes: 37 additions & 0 deletions codeception.dist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
paths:
tests: src/Test/Functional
output: tests/functional/_output
data: tests/functional/_data
support: vendor/magento/magento-cloud-docker/tests/functional/_support
actor_suffix: Tester
settings:
colors: true
extensions:
enabled:
- Codeception\Extension\RunFailed
- Codeception\Extension\FailedInfo
params:
- vendor/magento/magento-cloud-docker/tests/functional/configuration.dist.yml
- env
modules:
config:
Magento\CloudDocker\Test\Functional\Codeception\TestInfrastructure:
template_repo: "https://github.com/magento/magento-cloud.git"
mcd_repo: "https://github.com/magento/magento-cloud-docker.git"
mcc_repo: "https://github.com/magento/magento-cloud-components.git"
mcp_repo: "https://github.com/magento/magento-cloud-patches.git"
composer_magento_username: "%REPO_USERNAME%"
composer_magento_password: "%REPO_PASSWORD%"
composer_github_token: "%GITHUB_TOKEN%"
printOutput: false
Magento\CloudDocker\Test\Functional\Codeception\Docker:
system_magento_dir: "%Magento.docker.settings.system.magento_dir%"
printOutput: false
PhpBrowser:
url: "%Magento.docker.settings.env.url.base%"
Magento\CloudDocker\Test\Functional\Codeception\MagentoDb:
dsn: "mysql:host=%Magento.docker.settings.db.host%;port=%Magento.docker.settings.db.port%;dbname=%Magento.docker.settings.db.path%"
user: "%Magento.docker.settings.db.username%"
password: "%Magento.docker.settings.db.password%"
exposed_port: "%Magento.docker.settings.db.port%"
reconnect: true
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"symfony/process": "^2.1||^4.1"
},
"require-dev": {
"codeception/codeception": "^2.5.3",
"consolidation/robo": "^1.2",
"phpmd/phpmd": "@stable",
"phpunit/phpunit": "^6.2",
"squizlabs/php_codesniffer": "^3.0"
Expand All @@ -24,7 +26,8 @@
],
"autoload": {
"psr-4": {
"Magento\\CloudPatches\\": "src/"
"Magento\\CloudPatches\\": "src/",
"Magento\\CloudPatches\\Test\\Functional\\": "tests/functional/"
}
},
"scripts": {
Expand Down
7 changes: 7 additions & 0 deletions src/Test/Functional/Acceptance.suite.dist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
actor: CliTester
modules:
enabled:
- Magento\CloudDocker\Test\Functional\Codeception\TestInfrastructure
- Magento\CloudDocker\Test\Functional\Codeception\Docker
- PhpBrowser
- Asserts
27 changes: 27 additions & 0 deletions src/Test/Functional/Acceptance/Acceptance71Cest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\CloudPatches\Test\Functional\Acceptance;

/**
* @group php71
*/
class Acceptance71Cest extends AcceptanceCest
{
/**
* @return array
*/
protected function patchesDataProvider(): array
{
return [
['magentoVersion' => '2.1.16'],
['magentoVersion' => '2.1.18'],
['magentoVersion' => '2.2.0'],
['magentoVersion' => '2.2.11'],
];
}
}
25 changes: 25 additions & 0 deletions src/Test/Functional/Acceptance/Acceptance72Cest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\CloudPatches\Test\Functional\Acceptance;

/**
* @group php72
*/
class Acceptance72Cest extends AcceptanceCest
{
/**
* @return array
*/
protected function patchesDataProvider(): array
{
return [
['magentoVersion' => '2.3.0'],
['magentoVersion' => '2.3.2'],
];
}
}
99 changes: 99 additions & 0 deletions src/Test/Functional/Acceptance/AcceptanceCest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\CloudPatches\Test\Functional\Acceptance;

/**
* @group php73
*/
class AcceptanceCest
{
/**
* @param \CliTester $I
*/
public function _before(\CliTester $I): void
{
$I->cleanupWorkDir();
}

/**
* @param \CliTester $I
* @param string $magentoVersion
*/
protected function prepareTemplate(\CliTester $I, string $magentoVersion): void
{
$I->cloneTemplateToWorkDir($magentoVersion);
$I->createAuthJson();
$I->createArtifactsDir();
$I->createArtifactCurrentTestedCode('patches', '1.0.99');
$I->addArtifactsRepoToComposer();
$I->addEceDockerGitRepoToComposer();
$I->addDependencyToComposer('magento/magento-cloud-patches', '1.0.99');
$I->addDependencyToComposer(
'magento/magento-cloud-docker',
$I->getDependencyVersion('magento/magento-cloud-docker')
);
$I->composerUpdate();
}

/**
* @param \CliTester $I
* @param \Codeception\Example $data
* @throws \Robo\Exception\TaskException
* @dataProvider patchesDataProvider
*/
public function testPatches(\CliTester $I, \Codeception\Example $data): void
{
$this->prepareTemplate($I, $data['magentoVersion']);
$this->removeESIfExists($I);
$I->runEceDockerCommand('build:compose --mode=production');
$I->runDockerComposeCommand('run build cloud-build');
$I->startEnvironment();
$I->runDockerComposeCommand('run deploy cloud-deploy');
$I->runDockerComposeCommand('run deploy cloud-post-deploy');
$I->amOnPage('/');
$I->see('Home page');
$I->see('CMS homepage content goes here.');
}

/**
* @param \CliTester $I
*/
protected function removeESIfExists(\CliTester $I): void
{
$services = $I->readServicesYaml();

if (isset($services['elasticsearch'])) {
unset($services['elasticsearch']);
$I->writeServicesYaml($services);

$app = $I->readAppMagentoYaml();
unset($app['relationships']['elasticsearch']);
$I->writeAppMagentoYaml($app);
}
}

/**
* @return array
*/
protected function patchesDataProvider(): array
{
return [
['magentoVersion' => '2.3.3'],
['magentoVersion' => 'master'],
];
}

/**
* @param \CliTester $I
*/
public function _after(\CliTester $I): void
{
$I->stopEnvironment();
$I->removeWorkDir();
}
}
Empty file added tests/functional/_data/.gitkeep
Empty file.
9 changes: 9 additions & 0 deletions tests/functional/_data/files/debug_logging/.magento.env.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
stage:
global:
MIN_LOGGING_LEVEL: debug

log:
file:
min_level: "debug"
stream:
min_level: "debug"
2 changes: 2 additions & 0 deletions tests/functional/_output/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
19 changes: 19 additions & 0 deletions tests/travis/functional.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

# Copyright © Magento, Inc. All rights reserved.
# See COPYING.txt for license details.

set -e
trap '>&2 echo Error: Command \`$BASH_COMMAND\` on line $LINENO failed with exit code $?' ERR

case $TRAVIS_PHP_VERSION in
7.1)
./vendor/bin/codecept run -g php71 --steps
;;
7.2)
./vendor/bin/codecept run -g php72 --steps
;;
7.3)
./vendor/bin/codecept run -g php73 --steps
;;
esac
11 changes: 11 additions & 0 deletions tests/travis/static-unit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# Copyright © Magento, Inc. All rights reserved.
# See COPYING.txt for license details.

set -e
trap '>&2 echo Error: Command \`$BASH_COMMAND\` on line $LINENO failed with exit code $?' ERR

./vendor/bin/phpcs ./src --standard=./tests/static/phpcs-ruleset.xml -p -n
./vendor/bin/phpmd ./src xml ./tests/static/phpmd-ruleset.xml
./vendor/bin/phpunit --configuration ./tests/unit