diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index bc66824..bd358e0 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -52,8 +52,9 @@ jobs: strategy: matrix: prestashop_version: [ - "https://github.com/PrestaShop/PrestaShop/releases/download/8.0.0/prestashop_8.0.0.zip", - "https://github.com/PrestaShop/PrestaShop/releases/download/1.7.4.4/prestashop_1.7.4.4.zip", + "https://github.com/PrestaShop/PrestaShop/releases/download/1.7.8.11/prestashop_1.7.8.11.zip", + "https://github.com/PrestaShop/PrestaShop/releases/download/8.0.2/prestashop_8.0.2.zip", + "https://github.com/PrestaShop/PrestaShop/releases/download/8.1.3/prestashop_8.1.3.zip", ] steps: - name: Download PrestaShop code source @@ -111,8 +112,11 @@ jobs: - name: Install dependencies run: composer install - - name: PHPUnit tests 1.7 - run: DOCKER_INTERNAL="1.7" make phpunit + - name: PHPUnit tests 1.7.8.11 + run: DOCKER_INTERNAL="1.7.8.11" make phpunit - - name: PHPUnit tests with PS 8 - run: DOCKER_INTERNAL=8 make phpunit + - name: PHPUnit tests with PS 8.0.2 + run: DOCKER_INTERNAL="8.0.2" make phpunit + + - name: PHPUnit tests with PS latest + run: DOCKER_INTERNAL="latest" make phpunit diff --git a/Makefile b/Makefile index c3c79b3..f9b07aa 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ ifndef DOCKER endif phpunit: check-docker - docker pull prestashop/docker-internal-images:${DOCKER_INTERNAL} + docker build -f tests/.docker/${DOCKER_INTERNAL}/Dockerfile -t mbo-lib-installer/phpunit:${DOCKER_INTERNAL} tests/.docker/${DOCKER_INTERNAL} @docker run --rm \ --name phpunit \ -e PS_DOMAIN=localhost \ @@ -17,7 +17,7 @@ phpunit: check-docker -e XDEBUG_ENABLED=1 \ -v ${PWD}:/var/www/html/test-lib \ -w /var/www/html/test-lib \ - prestashop/docker-internal-images:${DOCKER_INTERNAL} \ + mbo-lib-installer/phpunit:${DOCKER_INTERNAL} \ sh -c " \ service mariadb start && \ service apache2 start && \ diff --git a/composer.json b/composer.json index 0385b8c..63ad1eb 100644 --- a/composer.json +++ b/composer.json @@ -5,8 +5,7 @@ "require": { "php": ">=7.2.5", "prestashop/module-lib-guzzle-adapter": "^1.0", - "ext-json": "*", - "symfony/translation": "^5.4" + "ext-json": "*" }, "config": { "platform": { @@ -15,8 +14,7 @@ }, "autoload": { "psr-4": { - "Prestashop\\ModuleLibMboInstaller\\": "src/", - "Symfony\\Component\\Translation\\": "vendor/symfony/translation" + "Prestashop\\ModuleLibMboInstaller\\": "src/" } }, "authors": [ diff --git a/composer.lock b/composer.lock index ba8b474..a58813e 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ae34815b83c276d3f0b479c9831f1c51", + "content-hash": "ae5dab1375ae0efcda76f86b9be14fb1", "packages": [ { "name": "clue/stream-filter", @@ -623,408 +623,6 @@ "source": "https://github.com/ralouphie/getallheaders/tree/develop" }, "time": "2019-03-08T08:55:37+00:00" - }, - { - "name": "symfony/deprecation-contracts", - "version": "v2.5.2", - "source": { - "type": "git", - "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/e8b495ea28c1d97b5e0c121748d6f9b53d075c66", - "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "2.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" - } - }, - "autoload": { - "files": [ - "function.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "A generic function and convention to trigger deprecation notices", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.2" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-01-02T09:53:40+00:00" - }, - { - "name": "symfony/polyfill-mbstring", - "version": "v1.29.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9773676c8a1bb1f8d4340a62efe641cf76eda7ec", - "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "provide": { - "ext-mbstring": "*" - }, - "suggest": { - "ext-mbstring": "For best performance" - }, - "type": "library", - "extra": { - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Mbstring\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for the Mbstring extension", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "mbstring", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.29.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-01-29T20:11:03+00:00" - }, - { - "name": "symfony/polyfill-php80", - "version": "v1.29.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/87b68208d5c1188808dd7839ee1e6c8ec3b02f1b", - "reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "type": "library", - "extra": { - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Php80\\": "" - }, - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ion Bazan", - "email": "ion.bazan@gmail.com" - }, - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.29.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-01-29T20:11:03+00:00" - }, - { - "name": "symfony/translation", - "version": "v5.4.35", - "source": { - "type": "git", - "url": "https://github.com/symfony/translation.git", - "reference": "77d7d1e46f52827585e65e6cd6f52a2542e59c72" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/77d7d1e46f52827585e65e6cd6f52a2542e59c72", - "reference": "77d7d1e46f52827585e65e6cd6f52a2542e59c72", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1|^3", - "symfony/polyfill-mbstring": "~1.0", - "symfony/polyfill-php80": "^1.16", - "symfony/translation-contracts": "^2.3" - }, - "conflict": { - "symfony/config": "<4.4", - "symfony/console": "<5.3", - "symfony/dependency-injection": "<5.0", - "symfony/http-kernel": "<5.0", - "symfony/twig-bundle": "<5.0", - "symfony/yaml": "<4.4" - }, - "provide": { - "symfony/translation-implementation": "2.3" - }, - "require-dev": { - "psr/log": "^1|^2|^3", - "symfony/config": "^4.4|^5.0|^6.0", - "symfony/console": "^5.4|^6.0", - "symfony/dependency-injection": "^5.0|^6.0", - "symfony/finder": "^4.4|^5.0|^6.0", - "symfony/http-client-contracts": "^1.1|^2.0|^3.0", - "symfony/http-kernel": "^5.0|^6.0", - "symfony/intl": "^4.4|^5.0|^6.0", - "symfony/polyfill-intl-icu": "^1.21", - "symfony/service-contracts": "^1.1.2|^2|^3", - "symfony/yaml": "^4.4|^5.0|^6.0" - }, - "suggest": { - "psr/log-implementation": "To use logging capability in translator", - "symfony/config": "", - "symfony/yaml": "" - }, - "type": "library", - "autoload": { - "files": [ - "Resources/functions.php" - ], - "psr-4": { - "Symfony\\Component\\Translation\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Provides tools to internationalize your application", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/translation/tree/v5.4.35" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-01-23T13:51:25+00:00" - }, - { - "name": "symfony/translation-contracts", - "version": "v2.5.2", - "source": { - "type": "git", - "url": "https://github.com/symfony/translation-contracts.git", - "reference": "136b19dd05cdf0709db6537d058bcab6dd6e2dbe" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/136b19dd05cdf0709db6537d058bcab6dd6e2dbe", - "reference": "136b19dd05cdf0709db6537d058bcab6dd6e2dbe", - "shasum": "" - }, - "require": { - "php": ">=7.2.5" - }, - "suggest": { - "symfony/translation-implementation": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "2.5-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Contracts\\Translation\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Generic abstractions related to translation", - "homepage": "https://symfony.com", - "keywords": [ - "abstractions", - "contracts", - "decoupling", - "interfaces", - "interoperability", - "standards" - ], - "support": { - "source": "https://github.com/symfony/translation-contracts/tree/v2.5.2" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2022-06-27T16:58:25+00:00" } ], "packages-dev": [ @@ -3552,6 +3150,73 @@ ], "time": "2024-01-23T14:28:09+00:00" }, + { + "name": "symfony/deprecation-contracts", + "version": "v2.5.2", + "source": { + "type": "git", + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/e8b495ea28c1d97b5e0c121748d6f9b53d075c66", + "reference": "e8b495ea28c1d97b5e0c121748d6f9b53d075c66", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.5-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "files": [ + "function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.2" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-01-02T09:53:40+00:00" + }, { "name": "symfony/event-dispatcher", "version": "v5.4.35", @@ -4150,6 +3815,86 @@ ], "time": "2024-01-29T20:11:03+00:00" }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.29.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9773676c8a1bb1f8d4340a62efe641cf76eda7ec", + "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "provide": { + "ext-mbstring": "*" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.29.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-01-29T20:11:03+00:00" + }, { "name": "symfony/polyfill-php73", "version": "v1.29.0", @@ -4226,6 +3971,86 @@ ], "time": "2024-01-29T20:11:03+00:00" }, + { + "name": "symfony/polyfill-php80", + "version": "v1.29.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/87b68208d5c1188808dd7839ee1e6c8ec3b02f1b", + "reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php80/tree/v1.29.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-01-29T20:11:03+00:00" + }, { "name": "symfony/polyfill-php81", "version": "v1.29.0", diff --git a/src/DependencyBuilder.php b/src/DependencyBuilder.php index 1f4bac1..554ff31 100644 --- a/src/DependencyBuilder.php +++ b/src/DependencyBuilder.php @@ -5,8 +5,6 @@ use Psr\Http\Client\ClientExceptionInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\Routing\Router; -use Symfony\Component\Translation\Loader\ArrayLoader; -use Symfony\Component\Translation\Translator; class DependencyBuilder { @@ -162,12 +160,6 @@ protected function buildDependenciesContext() $translationsLocale = str_replace('-', '_', self::DEFAULT_LOCALE); } - $translator = new Translator($translationsLocale); - $translator->addLoader('array', new ArrayLoader()); - $translator->addResource('array', [ - 'help_url_link' => $helpUrlTranslations[$translationsLocale], - ], $translationsLocale); - return [ 'module_display_name' => (string) $this->module->displayName, 'module_name' => (string) $this->module->name, @@ -175,7 +167,7 @@ protected function buildDependenciesContext() 'ps_version' => (string) _PS_VERSION_, 'php_version' => (string) PHP_VERSION, 'locale' => $currentLocale, - 'help_url' => $translator->trans('help_url_link'), + 'help_url' => $helpUrlTranslations[$translationsLocale], 'dependencies' => $this->getDependencies(true), ]; } @@ -297,12 +289,7 @@ protected function isMboNeeded() /** * @param bool $addRoutes * - * @return array<string, array{ - * "name": string, - * "installed": bool, - * "enabled": bool, - * "current_version": string, - * }>|array<ps_mbo, non-empty-array<string, bool|string>> + * @return array<string, array<string, mixed>> * * @throws \Exception */ @@ -329,7 +316,11 @@ private function getDependencies($addRoutes = false) $dependencies = []; foreach ($dependenciesContent as $dependency) { - if (!is_array($dependency) || !array_key_exists('name', $dependency)) { + if ( + !is_array($dependency) + || !array_key_exists('name', $dependency) + || !is_string($dependency['name']) + ) { continue; } @@ -408,11 +399,7 @@ private function getDependenciesSpecification() } /** - * @return array{ - * "dependencies": array<string, string|int|bool> - * } - * - * @throws \Exception + * @return array<string, string> */ private function getHelpUrlSpecification() { @@ -440,7 +427,7 @@ private function getHelpUrlSpecification() $helpUrlSpecificationFormatted = []; array_walk( $helpUrlSpecification, - function(string $value, string $key) use (&$helpUrlSpecificationFormatted) { + function (string $value, string $key) use (&$helpUrlSpecificationFormatted) { $helpUrlSpecificationFormatted[str_replace('-', '_', $key)] = $value; } ); @@ -456,6 +443,11 @@ function(string $value, string $key) use (&$helpUrlSpecificationFormatted) { return $helpUrlSpecification; } + /** + * @return mixed|null + * + * @throws \Exception + */ private function getConfigFileContent() { $dependencyFile = $this->module->getLocalPath() . self::DEPENDENCY_FILENAME; diff --git a/src/Presenter.php b/src/Presenter.php index 68b3096..0b73336 100644 --- a/src/Presenter.php +++ b/src/Presenter.php @@ -7,7 +7,7 @@ class Presenter { /** - * @return array<string, string|boolean|null> + * @return array<string, string|bool|null> */ public function present() { diff --git a/tests/.docker/1.7.8.11/Dockerfile b/tests/.docker/1.7.8.11/Dockerfile new file mode 100644 index 0000000..42996bb --- /dev/null +++ b/tests/.docker/1.7.8.11/Dockerfile @@ -0,0 +1,68 @@ +FROM prestashop/prestashop:1.7.8.11 + +MAINTAINER Ibrahima SOW <ibrahima.sow@prestashop.com> + +ENV GET_USER "" +ENV GET_FILE_MODULE "" +ENV ID_MODULE 0 +ENV PHP_MEMORY_LIMIT 256 + +ENV PS_HANDLE_DYNAMIC_DOMAIN 0 +ENV PS_INSTALL_AUTO 1 +ENV PS_DEV_MODE 1 +ENV PS_COUNTRY fr +# Allow some builds (CI for instance) to not install all languages +ARG INSTALL_LANGUAGES=1 +ENV PS_ALL_LANGUAGES ${INSTALL_LANGUAGES} +ENV PS_FOLDER_ADMIN admin-dev +ENV PS_FOLDER_INSTALL install-dev +ENV DB_SERVER localhost +ENV DB_USER macfly +ENV PS_ENABLE_SSL 1 + +ENV DEBIAN_FRONTEND noninteractive + +RUN apt update \ + && apt install -y default-mysql-server ssl-cert \ + && rm -rf /var/lib/apt/lists/* + +# XDebug extension +RUN pecl install xdebug-3.1.6 + +# MySQL installation +# Avoid MySQL questions during installation +RUN echo mysql-server-5.6 mysql-server/root_password password $DB_PASSWD | debconf-set-selections +RUN echo mysql-server-5.6 mysql-server/root_password_again password $DB_PASSWD | debconf-set-selections +# MySQL configuration +RUN sed -i -e"s/^bind-address\s*=\s*127.0.0.1/bind-address = 0.0.0.0/" /etc/mysql/mariadb.conf.d/50-server.cnf +EXPOSE 3306 + +# SSL configuration +RUN a2enmod ssl +RUN ln -s $APACHE_CONFDIR/sites-available/default-ssl.conf $APACHE_CONFDIR/sites-enabled/default-ssl.conf +EXPOSE 443 + +RUN echo '[mysql.server]\nservice-startup-timeout = -1' >> /etc/mysql/conf.d/startup.cnf +RUN service mariadb start \ +&& mysql -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED BY '$DB_PASSWD'; GRANT ALL PRIVILEGES ON *.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;" mysql \ + && mysqladmin -h $DB_SERVER -P $DB_PORT -u $DB_USER -p$DB_PASSWD create $DB_NAME --force + +COPY config_files/build/my-minimal.cnf /etc/mysql/conf.d/my-minimal.cnf +COPY config_files/docker-customization_run.sh /tmp/docker-customization_run.sh +COPY config_files/get-module.sh /tmp/get-module.sh +COPY config_files/update-domain.php /tmp/update-domain.php +RUN chmod u+x /tmp/docker-customization_run.sh /tmp/get-module.sh + +RUN sed -ie "s/post_max_size\ =\ 20M/post_max_size\ =\ 40M/g" /usr/local/etc/php/php.ini +RUN sed -ie "s/upload_max_filesize\ =\ 20M/upload_max_filesize\ =\ 40M/g" /usr/local/etc/php/php.ini + +RUN sed -i -e"s/^exec\s*apache2-foreground/#exec apache2-foreground/" /tmp/docker_run.sh +RUN service mariadb start && /tmp/docker_run.sh +RUN sed -i -e"s/^#exec\s*apache2-foreground/exec apache2-foreground/" /tmp/docker_run.sh + +COPY config_files/build/shop-build.php /tmp/build/shop-build.php +RUN service mariadb start \ + && runuser -g www-data -u www-data -- php /tmp/build/shop-build.php \ + && runuser -g www-data -u www-data -- php -d memory_limit=-1 bin/console cache:warmup --env=prod + +CMD ["/tmp/docker-customization_run.sh"] diff --git a/tests/.docker/1.7.8.11/config_files/build/my-minimal.cnf b/tests/.docker/1.7.8.11/config_files/build/my-minimal.cnf new file mode 100644 index 0000000..17faead --- /dev/null +++ b/tests/.docker/1.7.8.11/config_files/build/my-minimal.cnf @@ -0,0 +1,16 @@ +[mysqld] + +bind-address = 0.0.0.0 + +innodb_buffer_pool_size = 5242880 +innodb_fast_shutdown = 2 + +skip-innodb_doublewrite + +max_connections = 20 +query_cache_size = 0 +key_buffer_size = 8 +thread_cache_size = 0 +#host_cache_size = 0 +#join_buffer_size = 128 +#net_buffer_length = 1K diff --git a/tests/.docker/1.7.8.11/config_files/build/shop-build.php b/tests/.docker/1.7.8.11/config_files/build/shop-build.php new file mode 100644 index 0000000..04af00c --- /dev/null +++ b/tests/.docker/1.7.8.11/config_files/build/shop-build.php @@ -0,0 +1,40 @@ +<?php + +include '/var/www/html/config/config.inc.php'; + +// +// Add one employee per installed language +// + +echo PHP_EOL.'* Adding one employee per language...'.PHP_EOL; +foreach (Language::getLanguages() as $language) +{ + $employee = new Employee(); + $employee->id_profile = 1; + $employee->email = 'demo'. $language['iso_code'] .'@prestashop.com'; + $employee->id_lang = $language['id_lang']; + $employee->passwd = Tools::encrypt('prestashop_demo'); + $employee->active = 1; + $employee->optin = 1; + $employee->firstname = 'Demo'; + $employee->lastname = 'PrestaShop'; + $employee->stats_date_from = date('Y-m-d', strtotime('-1 month')); + $employee->stats_date_to = date('Y-m-d'); + $employee->stats_compare_from = '0000-00-00'; + $employee->stats_compare_to = '0000-00-00'; + $employee->stats_compare_option = 1; + $employee->bo_theme = 'default'; + $employee->bo_css = 'admin-theme.css'; + $employee->bo_width = 0; + $employee->bo_menu = 1; + $employee->default_tab = 1; + $employee->last_passwd_gen = date('Y-m-d H:i:s'); + $employee->add(); +} + +// +// Enable URL Rewriting +// + +echo PHP_EOL.'* Enable url rewriting...'.PHP_EOL; +Configuration::updateValue('PS_REWRITING_SETTINGS', 1); diff --git a/tests/.docker/1.7.8.11/config_files/docker-customization_run.sh b/tests/.docker/1.7.8.11/config_files/docker-customization_run.sh new file mode 100644 index 0000000..3230649 --- /dev/null +++ b/tests/.docker/1.7.8.11/config_files/docker-customization_run.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +echo "\n* Starting MySQL server ..."; +service mariadb start + +echo "\n* Updating PrestaShop domains ..."; +req='UPDATE ps_configuration SET value = "'$PS_DOMAIN'" WHERE name IN ("PS_SHOP_DOMAIN", "PS_SHOP_DOMAIN_SSL"); UPDATE ps_shop_url SET domain = "'$PS_DOMAIN'", domain_ssl = "'$PS_DOMAIN'";' +mysql -h$DB_SERVER -P$DB_PORT -u$DB_USER -p$DB_PASSWD -D$DB_NAME -e "${req}" & +runuser -g www-data -u www-data php /tmp/update-domain.php & + +req='UPDATE ps_configuration SET value = "'$PS_ENABLE_SSL'" WHERE name IN ("PS_SSL_ENABLED", "PS_SSL_ENABLED_EVERYWHERE");' +mysql -h$DB_SERVER -P$DB_PORT -u$DB_USER -p$DB_PASSWD -D$DB_NAME -e "${req}" & + +if [ "$ID_MODULE" != "0" ]; then + echo "\n* Requesting module $ID_MODULE ..."; + runuser -g www-data -u www-data bash /tmp/get-module.sh +fi + +if [ "$XDEBUG_ENABLED" == "1" ]; then + echo "\n* Enabling XDEBUG ..."; + docker-php-ext-enable xdebug +fi + +unset GET_USER +unset GET_FILE_MODULE + +echo "\n* Updating memory limit to ${PHP_MEMORY_LIMIT}M..."; +sed -ie "s/memory_limit\ =\ 256M/memory_limit\ =\ ${PHP_MEMORY_LIMIT}M/g" /usr/local/etc/php/php.ini + +bash /tmp/docker_run.sh diff --git a/tests/.docker/1.7.8.11/config_files/get-module.sh b/tests/.docker/1.7.8.11/config_files/get-module.sh new file mode 100755 index 0000000..557df05 --- /dev/null +++ b/tests/.docker/1.7.8.11/config_files/get-module.sh @@ -0,0 +1,100 @@ +#!/bin/bash + +# Unset ENV variables - conflict during Module installation +# +PS_DEV_MODE_ORIGIN=${PS_DEV_MODE} +unset PS_DEV_MODE +PS_DEMO_MODE_ORIGIN=${PS_DEMO_MODE} +unset PS_DEMO_MODE + + +# Handle zip download 1.7 +displayStatusMessage() { + local curl_error=$1 + + case $curl_error in + 1|3) + Message="The URL was not properly formatted or the URL protocol is not supported (curlCode ${curl_error})." + ;; + 2|4) + Message="This is likely to be an internal error or feature is not built-in (curlCode ${curl_error})." + ;; + 5|6|7) + Message="Couldn't resolve host/proxy or failed to connect() to host/proxy (curlCode ${curl_error})." + ;; + *) + Message="Error check man curl (curlCode ${curl_error})" + ;; + esac + + echo "${Message}" +} + +installModule() { + local moduleName=$1 + + echo "\n* Installing module $moduleName ..." + php bin/console prestashop:module install $moduleName + php bin/console prestashop:module configure $moduleName +} + +# Split id_module in list +IFS=', ' read -r -a ID_MODULE_LIST <<< "$ID_MODULE" +# Split module_name_toinstall in list +IFS=', ' read -r -a MODULE_NAME_TOINSTALL_LIST <<< "$MODULE_NAME_TOINSTALL" + +for index in "${!ID_MODULE_LIST[@]}" +do + echo "\n* Requesting module ${ID_MODULE_LIST[index]} ..."; + curl -u ${GET_USER} ${GET_FILE_MODULE}${ID_MODULE_LIST[index]} -L >> /var/www/html/modules/module.zip + + CMD_STATUS_CODE=$? + if [ ${CMD_STATUS_CODE} != 0 ] + then + displayStatusMessage ${CMD_STATUS_CODE} + else + if [ ! -f /var/www/html/modules/module.zip ] || [ ! -s /var/www/html/modules/module.zip ] + then + echo "\n* Unable to download module ${ID_MODULE_LIST[index]} ..." + else + echo "\n* Unzipping the module ${ID_MODULE_LIST[index]} ..."; + unzip -o -q /var/www/html/modules/module.zip -d /var/www/html/modules/ + if [ "$MODULE_NAME_TOINSTALL" == "ALL" ] + then + MODULE_NAME=$(basename $( \ + unzip -l modules/module.zip 2>&1 \ + | grep -E '^\s+[0-9]+\s+[0-9-]+\s+[0-9:]+' \ + | awk -F' ' '{print $4}'| head -1 + ) + ) + installModule ${MODULE_NAME} + fi + rm /var/www/html/modules/module.zip + fi + fi + echo "\n" +done + +# Module installation block +# +if [ "$MODULE_NAME_TOINSTALL" == "ALL" ] +then + echo "\n* Modules have already been installed [ All option ]" +else + for index in "${!MODULE_NAME_TOINSTALL_LIST[@]}" + do + if [ -d "modules/${MODULE_NAME_TOINSTALL_LIST[index]}" ] + then + installModule ${MODULE_NAME_TOINSTALL_LIST[index]} + else + echo "\n* module ${MODULE_NAME_TOINSTALL_LIST[index]} is not present on modules directory ..." + fi + done +fi + +# Restore ENV variables +export PS_DEV_MODE=${PS_DEV_MODE_ORIGIN} +unset PS_DEV_MODE_ORIGIN +export PS_DEMO_MODE=${PS_DEMO_MODE_ORIGIN} +unset PS_DEMO_MODE_ORIGIN + diff --git a/tests/.docker/1.7.8.11/config_files/update-domain.php b/tests/.docker/1.7.8.11/config_files/update-domain.php new file mode 100644 index 0000000..7bd5d95 --- /dev/null +++ b/tests/.docker/1.7.8.11/config_files/update-domain.php @@ -0,0 +1,5 @@ +<?php + +include '/var/www/html/config/config.inc.php'; + +Tools::generateHtaccess(); diff --git a/tests/.docker/8.0.2/Dockerfile b/tests/.docker/8.0.2/Dockerfile new file mode 100644 index 0000000..945403c --- /dev/null +++ b/tests/.docker/8.0.2/Dockerfile @@ -0,0 +1,68 @@ +FROM prestashop/prestashop:8.0.2 + +MAINTAINER Ibrahima SOW <ibrahima.sow@prestashop.com> + +ENV GET_USER "" +ENV GET_FILE_MODULE "" +ENV ID_MODULE 0 +ENV PHP_MEMORY_LIMIT 256 + +ENV PS_HANDLE_DYNAMIC_DOMAIN 0 +ENV PS_INSTALL_AUTO 1 +ENV PS_DEV_MODE 1 +ENV PS_COUNTRY fr +# Allow some builds (CI for instance) to not install all languages +ARG INSTALL_LANGUAGES=1 +ENV PS_ALL_LANGUAGES ${INSTALL_LANGUAGES} +ENV PS_FOLDER_ADMIN admin-dev +ENV PS_FOLDER_INSTALL install-dev +ENV DB_SERVER localhost +ENV DB_USER macfly +ENV PS_ENABLE_SSL 1 + +ENV DEBIAN_FRONTEND noninteractive + +RUN apt update \ + && apt install -y default-mysql-server ssl-cert \ + && rm -rf /var/lib/apt/lists/* + +# XDebug extension +RUN pecl install xdebug + +# MySQL installation +# Avoid MySQL questions during installation +RUN echo mysql-server-5.6 mysql-server/root_password password $DB_PASSWD | debconf-set-selections +RUN echo mysql-server-5.6 mysql-server/root_password_again password $DB_PASSWD | debconf-set-selections +# MySQL configuration +RUN sed -i -e"s/^bind-address\s*=\s*127.0.0.1/bind-address = 0.0.0.0/" /etc/mysql/mariadb.conf.d/50-server.cnf +EXPOSE 3306 + +# SSL configuration +RUN a2enmod ssl +RUN ln -s $APACHE_CONFDIR/sites-available/default-ssl.conf $APACHE_CONFDIR/sites-enabled/default-ssl.conf +EXPOSE 443 + +RUN echo '[mysql.server]\nservice-startup-timeout = -1' >> /etc/mysql/conf.d/startup.cnf +RUN service mariadb start \ +&& mysql -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED BY '$DB_PASSWD'; GRANT ALL PRIVILEGES ON *.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;" mysql \ + && mysqladmin -h $DB_SERVER -P $DB_PORT -u $DB_USER -p$DB_PASSWD create $DB_NAME --force + +COPY config_files/build/my-minimal.cnf /etc/mysql/conf.d/my-minimal.cnf +COPY config_files/docker-customization_run.sh /tmp/docker-customization_run.sh +COPY config_files/get-module.sh /tmp/get-module.sh +COPY config_files/update-domain.php /tmp/update-domain.php +RUN chmod u+x /tmp/docker-customization_run.sh /tmp/get-module.sh + +RUN sed -ie "s/post_max_size\ =\ 20M/post_max_size\ =\ 40M/g" /usr/local/etc/php/php.ini +RUN sed -ie "s/upload_max_filesize\ =\ 20M/upload_max_filesize\ =\ 40M/g" /usr/local/etc/php/php.ini + +RUN sed -i -e"s/^exec\s*apache2-foreground/#exec apache2-foreground/" /tmp/docker_run.sh +RUN service mariadb start && /tmp/docker_run.sh +RUN sed -i -e"s/^#exec\s*apache2-foreground/exec apache2-foreground/" /tmp/docker_run.sh + +COPY config_files/build/shop-build.php /tmp/build/shop-build.php +RUN service mariadb start \ + && runuser -g www-data -u www-data -- php /tmp/build/shop-build.php \ + && runuser -g www-data -u www-data -- php -d memory_limit=-1 bin/console cache:warmup --env=prod + +CMD ["/tmp/docker-customization_run.sh"] diff --git a/tests/.docker/8.0.2/config_files/build/my-minimal.cnf b/tests/.docker/8.0.2/config_files/build/my-minimal.cnf new file mode 100644 index 0000000..17faead --- /dev/null +++ b/tests/.docker/8.0.2/config_files/build/my-minimal.cnf @@ -0,0 +1,16 @@ +[mysqld] + +bind-address = 0.0.0.0 + +innodb_buffer_pool_size = 5242880 +innodb_fast_shutdown = 2 + +skip-innodb_doublewrite + +max_connections = 20 +query_cache_size = 0 +key_buffer_size = 8 +thread_cache_size = 0 +#host_cache_size = 0 +#join_buffer_size = 128 +#net_buffer_length = 1K diff --git a/tests/.docker/8.0.2/config_files/build/shop-build.php b/tests/.docker/8.0.2/config_files/build/shop-build.php new file mode 100644 index 0000000..04af00c --- /dev/null +++ b/tests/.docker/8.0.2/config_files/build/shop-build.php @@ -0,0 +1,40 @@ +<?php + +include '/var/www/html/config/config.inc.php'; + +// +// Add one employee per installed language +// + +echo PHP_EOL.'* Adding one employee per language...'.PHP_EOL; +foreach (Language::getLanguages() as $language) +{ + $employee = new Employee(); + $employee->id_profile = 1; + $employee->email = 'demo'. $language['iso_code'] .'@prestashop.com'; + $employee->id_lang = $language['id_lang']; + $employee->passwd = Tools::encrypt('prestashop_demo'); + $employee->active = 1; + $employee->optin = 1; + $employee->firstname = 'Demo'; + $employee->lastname = 'PrestaShop'; + $employee->stats_date_from = date('Y-m-d', strtotime('-1 month')); + $employee->stats_date_to = date('Y-m-d'); + $employee->stats_compare_from = '0000-00-00'; + $employee->stats_compare_to = '0000-00-00'; + $employee->stats_compare_option = 1; + $employee->bo_theme = 'default'; + $employee->bo_css = 'admin-theme.css'; + $employee->bo_width = 0; + $employee->bo_menu = 1; + $employee->default_tab = 1; + $employee->last_passwd_gen = date('Y-m-d H:i:s'); + $employee->add(); +} + +// +// Enable URL Rewriting +// + +echo PHP_EOL.'* Enable url rewriting...'.PHP_EOL; +Configuration::updateValue('PS_REWRITING_SETTINGS', 1); diff --git a/tests/.docker/8.0.2/config_files/docker-customization_run.sh b/tests/.docker/8.0.2/config_files/docker-customization_run.sh new file mode 100644 index 0000000..3230649 --- /dev/null +++ b/tests/.docker/8.0.2/config_files/docker-customization_run.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +echo "\n* Starting MySQL server ..."; +service mariadb start + +echo "\n* Updating PrestaShop domains ..."; +req='UPDATE ps_configuration SET value = "'$PS_DOMAIN'" WHERE name IN ("PS_SHOP_DOMAIN", "PS_SHOP_DOMAIN_SSL"); UPDATE ps_shop_url SET domain = "'$PS_DOMAIN'", domain_ssl = "'$PS_DOMAIN'";' +mysql -h$DB_SERVER -P$DB_PORT -u$DB_USER -p$DB_PASSWD -D$DB_NAME -e "${req}" & +runuser -g www-data -u www-data php /tmp/update-domain.php & + +req='UPDATE ps_configuration SET value = "'$PS_ENABLE_SSL'" WHERE name IN ("PS_SSL_ENABLED", "PS_SSL_ENABLED_EVERYWHERE");' +mysql -h$DB_SERVER -P$DB_PORT -u$DB_USER -p$DB_PASSWD -D$DB_NAME -e "${req}" & + +if [ "$ID_MODULE" != "0" ]; then + echo "\n* Requesting module $ID_MODULE ..."; + runuser -g www-data -u www-data bash /tmp/get-module.sh +fi + +if [ "$XDEBUG_ENABLED" == "1" ]; then + echo "\n* Enabling XDEBUG ..."; + docker-php-ext-enable xdebug +fi + +unset GET_USER +unset GET_FILE_MODULE + +echo "\n* Updating memory limit to ${PHP_MEMORY_LIMIT}M..."; +sed -ie "s/memory_limit\ =\ 256M/memory_limit\ =\ ${PHP_MEMORY_LIMIT}M/g" /usr/local/etc/php/php.ini + +bash /tmp/docker_run.sh diff --git a/tests/.docker/8.0.2/config_files/get-module.sh b/tests/.docker/8.0.2/config_files/get-module.sh new file mode 100755 index 0000000..557df05 --- /dev/null +++ b/tests/.docker/8.0.2/config_files/get-module.sh @@ -0,0 +1,100 @@ +#!/bin/bash + +# Unset ENV variables - conflict during Module installation +# +PS_DEV_MODE_ORIGIN=${PS_DEV_MODE} +unset PS_DEV_MODE +PS_DEMO_MODE_ORIGIN=${PS_DEMO_MODE} +unset PS_DEMO_MODE + + +# Handle zip download 1.7 +displayStatusMessage() { + local curl_error=$1 + + case $curl_error in + 1|3) + Message="The URL was not properly formatted or the URL protocol is not supported (curlCode ${curl_error})." + ;; + 2|4) + Message="This is likely to be an internal error or feature is not built-in (curlCode ${curl_error})." + ;; + 5|6|7) + Message="Couldn't resolve host/proxy or failed to connect() to host/proxy (curlCode ${curl_error})." + ;; + *) + Message="Error check man curl (curlCode ${curl_error})" + ;; + esac + + echo "${Message}" +} + +installModule() { + local moduleName=$1 + + echo "\n* Installing module $moduleName ..." + php bin/console prestashop:module install $moduleName + php bin/console prestashop:module configure $moduleName +} + +# Split id_module in list +IFS=', ' read -r -a ID_MODULE_LIST <<< "$ID_MODULE" +# Split module_name_toinstall in list +IFS=', ' read -r -a MODULE_NAME_TOINSTALL_LIST <<< "$MODULE_NAME_TOINSTALL" + +for index in "${!ID_MODULE_LIST[@]}" +do + echo "\n* Requesting module ${ID_MODULE_LIST[index]} ..."; + curl -u ${GET_USER} ${GET_FILE_MODULE}${ID_MODULE_LIST[index]} -L >> /var/www/html/modules/module.zip + + CMD_STATUS_CODE=$? + if [ ${CMD_STATUS_CODE} != 0 ] + then + displayStatusMessage ${CMD_STATUS_CODE} + else + if [ ! -f /var/www/html/modules/module.zip ] || [ ! -s /var/www/html/modules/module.zip ] + then + echo "\n* Unable to download module ${ID_MODULE_LIST[index]} ..." + else + echo "\n* Unzipping the module ${ID_MODULE_LIST[index]} ..."; + unzip -o -q /var/www/html/modules/module.zip -d /var/www/html/modules/ + if [ "$MODULE_NAME_TOINSTALL" == "ALL" ] + then + MODULE_NAME=$(basename $( \ + unzip -l modules/module.zip 2>&1 \ + | grep -E '^\s+[0-9]+\s+[0-9-]+\s+[0-9:]+' \ + | awk -F' ' '{print $4}'| head -1 + ) + ) + installModule ${MODULE_NAME} + fi + rm /var/www/html/modules/module.zip + fi + fi + echo "\n" +done + +# Module installation block +# +if [ "$MODULE_NAME_TOINSTALL" == "ALL" ] +then + echo "\n* Modules have already been installed [ All option ]" +else + for index in "${!MODULE_NAME_TOINSTALL_LIST[@]}" + do + if [ -d "modules/${MODULE_NAME_TOINSTALL_LIST[index]}" ] + then + installModule ${MODULE_NAME_TOINSTALL_LIST[index]} + else + echo "\n* module ${MODULE_NAME_TOINSTALL_LIST[index]} is not present on modules directory ..." + fi + done +fi + +# Restore ENV variables +export PS_DEV_MODE=${PS_DEV_MODE_ORIGIN} +unset PS_DEV_MODE_ORIGIN +export PS_DEMO_MODE=${PS_DEMO_MODE_ORIGIN} +unset PS_DEMO_MODE_ORIGIN + diff --git a/tests/.docker/8.0.2/config_files/update-domain.php b/tests/.docker/8.0.2/config_files/update-domain.php new file mode 100644 index 0000000..7bd5d95 --- /dev/null +++ b/tests/.docker/8.0.2/config_files/update-domain.php @@ -0,0 +1,5 @@ +<?php + +include '/var/www/html/config/config.inc.php'; + +Tools::generateHtaccess(); diff --git a/tests/.docker/latest/Dockerfile b/tests/.docker/latest/Dockerfile new file mode 100644 index 0000000..44105ce --- /dev/null +++ b/tests/.docker/latest/Dockerfile @@ -0,0 +1,68 @@ +FROM prestashop/prestashop:latest + +MAINTAINER Ibrahima SOW <ibrahima.sow@prestashop.com> + +ENV GET_USER "" +ENV GET_FILE_MODULE "" +ENV ID_MODULE 0 +ENV PHP_MEMORY_LIMIT 256 + +ENV PS_HANDLE_DYNAMIC_DOMAIN 0 +ENV PS_INSTALL_AUTO 1 +ENV PS_DEV_MODE 1 +ENV PS_COUNTRY fr +# Allow some builds (CI for instance) to not install all languages +ARG INSTALL_LANGUAGES=1 +ENV PS_ALL_LANGUAGES ${INSTALL_LANGUAGES} +ENV PS_FOLDER_ADMIN admin-dev +ENV PS_FOLDER_INSTALL install-dev +ENV DB_SERVER localhost +ENV DB_USER macfly +ENV PS_ENABLE_SSL 1 + +ENV DEBIAN_FRONTEND noninteractive + +RUN apt update \ + && apt install -y default-mysql-server ssl-cert \ + && rm -rf /var/lib/apt/lists/* + +# XDebug extension +RUN pecl install xdebug + +# MySQL installation +# Avoid MySQL questions during installation +RUN echo mysql-server-5.6 mysql-server/root_password password $DB_PASSWD | debconf-set-selections +RUN echo mysql-server-5.6 mysql-server/root_password_again password $DB_PASSWD | debconf-set-selections +# MySQL configuration +RUN sed -i -e"s/^bind-address\s*=\s*127.0.0.1/bind-address = 0.0.0.0/" /etc/mysql/mariadb.conf.d/50-server.cnf +EXPOSE 3306 + +# SSL configuration +RUN a2enmod ssl +RUN ln -s $APACHE_CONFDIR/sites-available/default-ssl.conf $APACHE_CONFDIR/sites-enabled/default-ssl.conf +EXPOSE 443 + +RUN echo '[mysql.server]\nservice-startup-timeout = -1' >> /etc/mysql/conf.d/startup.cnf +RUN service mariadb start \ +&& mysql -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED BY '$DB_PASSWD'; GRANT ALL PRIVILEGES ON *.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;" mysql \ + && mysqladmin -h $DB_SERVER -P $DB_PORT -u $DB_USER -p$DB_PASSWD create $DB_NAME --force + +COPY config_files/build/my-minimal.cnf /etc/mysql/conf.d/my-minimal.cnf +COPY config_files/docker-customization_run.sh /tmp/docker-customization_run.sh +COPY config_files/get-module.sh /tmp/get-module.sh +COPY config_files/update-domain.php /tmp/update-domain.php +RUN chmod u+x /tmp/docker-customization_run.sh /tmp/get-module.sh + +RUN sed -ie "s/post_max_size\ =\ 20M/post_max_size\ =\ 40M/g" /usr/local/etc/php/php.ini +RUN sed -ie "s/upload_max_filesize\ =\ 20M/upload_max_filesize\ =\ 40M/g" /usr/local/etc/php/php.ini + +RUN sed -i -e"s/^exec\s*apache2-foreground/#exec apache2-foreground/" /tmp/docker_run.sh +RUN service mariadb start && /tmp/docker_run.sh +RUN sed -i -e"s/^#exec\s*apache2-foreground/exec apache2-foreground/" /tmp/docker_run.sh + +COPY config_files/build/shop-build.php /tmp/build/shop-build.php +RUN service mariadb start \ + && runuser -g www-data -u www-data -- php /tmp/build/shop-build.php \ + && runuser -g www-data -u www-data -- php -d memory_limit=-1 bin/console cache:warmup --env=prod + +CMD ["/tmp/docker-customization_run.sh"] diff --git a/tests/.docker/latest/config_files/build/my-minimal.cnf b/tests/.docker/latest/config_files/build/my-minimal.cnf new file mode 100644 index 0000000..17faead --- /dev/null +++ b/tests/.docker/latest/config_files/build/my-minimal.cnf @@ -0,0 +1,16 @@ +[mysqld] + +bind-address = 0.0.0.0 + +innodb_buffer_pool_size = 5242880 +innodb_fast_shutdown = 2 + +skip-innodb_doublewrite + +max_connections = 20 +query_cache_size = 0 +key_buffer_size = 8 +thread_cache_size = 0 +#host_cache_size = 0 +#join_buffer_size = 128 +#net_buffer_length = 1K diff --git a/tests/.docker/latest/config_files/build/shop-build.php b/tests/.docker/latest/config_files/build/shop-build.php new file mode 100644 index 0000000..04af00c --- /dev/null +++ b/tests/.docker/latest/config_files/build/shop-build.php @@ -0,0 +1,40 @@ +<?php + +include '/var/www/html/config/config.inc.php'; + +// +// Add one employee per installed language +// + +echo PHP_EOL.'* Adding one employee per language...'.PHP_EOL; +foreach (Language::getLanguages() as $language) +{ + $employee = new Employee(); + $employee->id_profile = 1; + $employee->email = 'demo'. $language['iso_code'] .'@prestashop.com'; + $employee->id_lang = $language['id_lang']; + $employee->passwd = Tools::encrypt('prestashop_demo'); + $employee->active = 1; + $employee->optin = 1; + $employee->firstname = 'Demo'; + $employee->lastname = 'PrestaShop'; + $employee->stats_date_from = date('Y-m-d', strtotime('-1 month')); + $employee->stats_date_to = date('Y-m-d'); + $employee->stats_compare_from = '0000-00-00'; + $employee->stats_compare_to = '0000-00-00'; + $employee->stats_compare_option = 1; + $employee->bo_theme = 'default'; + $employee->bo_css = 'admin-theme.css'; + $employee->bo_width = 0; + $employee->bo_menu = 1; + $employee->default_tab = 1; + $employee->last_passwd_gen = date('Y-m-d H:i:s'); + $employee->add(); +} + +// +// Enable URL Rewriting +// + +echo PHP_EOL.'* Enable url rewriting...'.PHP_EOL; +Configuration::updateValue('PS_REWRITING_SETTINGS', 1); diff --git a/tests/.docker/latest/config_files/docker-customization_run.sh b/tests/.docker/latest/config_files/docker-customization_run.sh new file mode 100644 index 0000000..3230649 --- /dev/null +++ b/tests/.docker/latest/config_files/docker-customization_run.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +echo "\n* Starting MySQL server ..."; +service mariadb start + +echo "\n* Updating PrestaShop domains ..."; +req='UPDATE ps_configuration SET value = "'$PS_DOMAIN'" WHERE name IN ("PS_SHOP_DOMAIN", "PS_SHOP_DOMAIN_SSL"); UPDATE ps_shop_url SET domain = "'$PS_DOMAIN'", domain_ssl = "'$PS_DOMAIN'";' +mysql -h$DB_SERVER -P$DB_PORT -u$DB_USER -p$DB_PASSWD -D$DB_NAME -e "${req}" & +runuser -g www-data -u www-data php /tmp/update-domain.php & + +req='UPDATE ps_configuration SET value = "'$PS_ENABLE_SSL'" WHERE name IN ("PS_SSL_ENABLED", "PS_SSL_ENABLED_EVERYWHERE");' +mysql -h$DB_SERVER -P$DB_PORT -u$DB_USER -p$DB_PASSWD -D$DB_NAME -e "${req}" & + +if [ "$ID_MODULE" != "0" ]; then + echo "\n* Requesting module $ID_MODULE ..."; + runuser -g www-data -u www-data bash /tmp/get-module.sh +fi + +if [ "$XDEBUG_ENABLED" == "1" ]; then + echo "\n* Enabling XDEBUG ..."; + docker-php-ext-enable xdebug +fi + +unset GET_USER +unset GET_FILE_MODULE + +echo "\n* Updating memory limit to ${PHP_MEMORY_LIMIT}M..."; +sed -ie "s/memory_limit\ =\ 256M/memory_limit\ =\ ${PHP_MEMORY_LIMIT}M/g" /usr/local/etc/php/php.ini + +bash /tmp/docker_run.sh diff --git a/tests/.docker/latest/config_files/get-module.sh b/tests/.docker/latest/config_files/get-module.sh new file mode 100755 index 0000000..557df05 --- /dev/null +++ b/tests/.docker/latest/config_files/get-module.sh @@ -0,0 +1,100 @@ +#!/bin/bash + +# Unset ENV variables - conflict during Module installation +# +PS_DEV_MODE_ORIGIN=${PS_DEV_MODE} +unset PS_DEV_MODE +PS_DEMO_MODE_ORIGIN=${PS_DEMO_MODE} +unset PS_DEMO_MODE + + +# Handle zip download 1.7 +displayStatusMessage() { + local curl_error=$1 + + case $curl_error in + 1|3) + Message="The URL was not properly formatted or the URL protocol is not supported (curlCode ${curl_error})." + ;; + 2|4) + Message="This is likely to be an internal error or feature is not built-in (curlCode ${curl_error})." + ;; + 5|6|7) + Message="Couldn't resolve host/proxy or failed to connect() to host/proxy (curlCode ${curl_error})." + ;; + *) + Message="Error check man curl (curlCode ${curl_error})" + ;; + esac + + echo "${Message}" +} + +installModule() { + local moduleName=$1 + + echo "\n* Installing module $moduleName ..." + php bin/console prestashop:module install $moduleName + php bin/console prestashop:module configure $moduleName +} + +# Split id_module in list +IFS=', ' read -r -a ID_MODULE_LIST <<< "$ID_MODULE" +# Split module_name_toinstall in list +IFS=', ' read -r -a MODULE_NAME_TOINSTALL_LIST <<< "$MODULE_NAME_TOINSTALL" + +for index in "${!ID_MODULE_LIST[@]}" +do + echo "\n* Requesting module ${ID_MODULE_LIST[index]} ..."; + curl -u ${GET_USER} ${GET_FILE_MODULE}${ID_MODULE_LIST[index]} -L >> /var/www/html/modules/module.zip + + CMD_STATUS_CODE=$? + if [ ${CMD_STATUS_CODE} != 0 ] + then + displayStatusMessage ${CMD_STATUS_CODE} + else + if [ ! -f /var/www/html/modules/module.zip ] || [ ! -s /var/www/html/modules/module.zip ] + then + echo "\n* Unable to download module ${ID_MODULE_LIST[index]} ..." + else + echo "\n* Unzipping the module ${ID_MODULE_LIST[index]} ..."; + unzip -o -q /var/www/html/modules/module.zip -d /var/www/html/modules/ + if [ "$MODULE_NAME_TOINSTALL" == "ALL" ] + then + MODULE_NAME=$(basename $( \ + unzip -l modules/module.zip 2>&1 \ + | grep -E '^\s+[0-9]+\s+[0-9-]+\s+[0-9:]+' \ + | awk -F' ' '{print $4}'| head -1 + ) + ) + installModule ${MODULE_NAME} + fi + rm /var/www/html/modules/module.zip + fi + fi + echo "\n" +done + +# Module installation block +# +if [ "$MODULE_NAME_TOINSTALL" == "ALL" ] +then + echo "\n* Modules have already been installed [ All option ]" +else + for index in "${!MODULE_NAME_TOINSTALL_LIST[@]}" + do + if [ -d "modules/${MODULE_NAME_TOINSTALL_LIST[index]}" ] + then + installModule ${MODULE_NAME_TOINSTALL_LIST[index]} + else + echo "\n* module ${MODULE_NAME_TOINSTALL_LIST[index]} is not present on modules directory ..." + fi + done +fi + +# Restore ENV variables +export PS_DEV_MODE=${PS_DEV_MODE_ORIGIN} +unset PS_DEV_MODE_ORIGIN +export PS_DEMO_MODE=${PS_DEMO_MODE_ORIGIN} +unset PS_DEMO_MODE_ORIGIN + diff --git a/tests/.docker/latest/config_files/update-domain.php b/tests/.docker/latest/config_files/update-domain.php new file mode 100644 index 0000000..7bd5d95 --- /dev/null +++ b/tests/.docker/latest/config_files/update-domain.php @@ -0,0 +1,5 @@ +<?php + +include '/var/www/html/config/config.inc.php'; + +Tools::generateHtaccess(); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 4f32082..61141bb 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -19,6 +19,6 @@ global $kernel; if (!$kernel) { require_once _PS_ROOT_DIR_ . '/app/AppKernel.php'; - $kernel = new \AppKernel('dev', true); + $kernel = new AppKernel('dev', true); $kernel->boot(); }