diff --git a/.env b/.env deleted file mode 100644 index 308728b..0000000 --- a/.env +++ /dev/null @@ -1 +0,0 @@ -COMPOSE_PROJECT_NAME=getresponse-for-prestashop \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 5ad859e..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,57 +0,0 @@ -stages: - - install_dependencies - - test - - upload_to_s3 - -workflow: - rules: - # Run detached pipeline for Merge Requests - - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' - # Do NOT run redundant pipeline for branch if MR is opened for that branch - - if: '$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS' - when: never - # Run pipeline for branches without related MR (jobs' rules will narrow this requirement) - - if: '$CI_COMMIT_BRANCH || $CI_COMMIT_TAG' - -.exclude-master: &exclude-master - rules: - - if: $CI_COMMIT_BRANCH != "master" - -composer install:php71: - image: php:7.1-cli - stage: install_dependencies - before_script: - - apt-get update - - apt-get install -y git unzip - - php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" - - php composer-setup.php - - php -r "unlink('composer-setup.php');" - script: - - php composer.phar update - artifacts: - paths: - - vendor/ - expire_in: 2 hrs - <<: *exclude-master - -test:app-php71: - image: php:7.1-cli - stage: test - tags: - - kubernetes-ci - script: - - ./vendor/bin/phpunit --testsuite unit --configuration ./tests/phpunit.xml --colors=never - <<: *exclude-master - dependencies: - - composer install:php71 - -upload to s3: - stage: upload_to_s3 - rules: - - if: $CI_COMMIT_TAG - tags: - - kubernetes-us - script: - - tar --exclude='.git' --exclude='composer.*' --exclude='.gitignore' --exclude='.gitlab-ci.yml' --exclude='README.md' --exclude='CHANGELOG.md' --exclude='Makefile' -czf /tmp/$CI_COMMIT_TAG.tar.gz . - - mv /tmp/$CI_COMMIT_TAG.tar.gz . - - aws --only-show-errors --endpoint-url https://s3.eu-central-1.amazonaws.com s3 cp $CI_COMMIT_TAG.tar.gz s3://gr-deployment/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME/releases/ diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..bae99bf --- /dev/null +++ b/.htaccess @@ -0,0 +1,15 @@ +# Apache 2.2 + + + order allow,deny + deny from all + + + +# Apache 2.4 + + + order allow,deny + deny from all + + \ No newline at end of file diff --git a/.php_cs.dist b/.php_cs.dist deleted file mode 100644 index f1200ad..0000000 --- a/.php_cs.dist +++ /dev/null @@ -1,47 +0,0 @@ -in(__DIR__) - ->name('*.php') - ->ignoreDotFiles(true) - ->ignoreVCS(true); - -return (new PhpCsFixer\Config()) - ->setRiskyAllowed(true) - ->setRules([ - '@Symfony' => true, - 'array_indentation' => true, - 'cast_spaces' => [ - 'space' => 'single', - ], - 'combine_consecutive_issets' => true, - 'concat_space' => [ - 'spacing' => 'one', - ], - 'error_suppression' => [ - 'mute_deprecation_error' => false, - 'noise_remaining_usages' => false, - 'noise_remaining_usages_exclude' => [], - ], - 'function_to_constant' => false, - 'method_chaining_indentation' => true, - 'no_alias_functions' => false, - 'no_superfluous_phpdoc_tags' => false, - 'non_printable_character' => [ - 'use_escape_sequences_in_strings' => true, - ], - 'phpdoc_align' => [ - 'align' => 'left', - ], - 'phpdoc_summary' => false, - 'protected_to_private' => false, - 'psr4' => false, - 'self_accessor' => false, - 'yoda_style' => null, - 'single_line_throw' => false, - 'no_alias_language_construct_call' => false, - ]) - ->setFinder($finder) - ->setCacheFile(__DIR__.'/.php_cs.cache'); \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a9acc5..d19d6f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,33 @@ # Changelog +## [1.5.0] - 2024-12-18 +### Feature +- Added support for cart recovery for non-logged-in users + +## [1.4.2] - 2024-10-31 +### Feature +- Change storage from cookie to session + +## [1.4.1] - 2024-07-26 +### Feature +- Compatibility verified for Prestashop 8.1.7 + +## [1.4.0] - 2024-07-16 +### Feature +- Added product_id in payload when sending product, order and customer + +## [1.3.4] - 2024-07-02 +### Fix +- Fixed: missing vendor catalog + +## [1.3.3] - 2024-05-13 +### Fix +- Fixed: newsletter name field getting from $_POST array + +## [1.3.2] - 2024-02-27 +### Feature +- Added prestashop 8 support + ## [1.3.1] - 2024-01-15 ### Fix - Added TrackingCode events optimisation diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 5fd3b22..0000000 --- a/Dockerfile +++ /dev/null @@ -1,36 +0,0 @@ -FROM php:5.6-cli as php5 -RUN mv /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini -RUN pecl channel-update pecl.php.net -RUN pecl install http://pecl.php.net/get/xdebug-2.5.5.tgz \ - && docker-php-ext-enable xdebug -WORKDIR /plugin -COPY --from=docker.int.getresponse.com/docker/composer:2.2.9 /usr/bin/composer /usr/bin/composer -COPY . ./ -RUN sed -i -e 's/deb.debian.org/archive.debian.org/g' \ - -e 's|security.debian.org|archive.debian.org/|g' \ - -e '/stretch-updates/d' /etc/apt/sources.list -RUN apt-get update \ - && apt-get upgrade -y \ - && apt-get install -y \ - unzip -RUN composer update --no-interaction --prefer-dist --no-suggest --no-cache -ENTRYPOINT [ "/bin/bash", "-c", "tail -f /dev/null" ] - -FROM php:7.1-cli as php7 -RUN mv /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini -RUN pecl channel-update pecl.php.net -RUN pecl install http://pecl.php.net/get/xdebug-2.9.0.tgz \ - && docker-php-ext-enable xdebug -WORKDIR /plugin -COPY --from=docker.int.getresponse.com/docker/composer:2.2.9 /usr/bin/composer /usr/bin/composer -COPY . ./ -RUN apt-get update \ - && apt-get upgrade -y \ - && apt-get install -y \ - unzip -RUN composer update --no-interaction --prefer-dist --no-suggest --no-cache -RUN printf "zend_extension=xdebug.so\nxdebug.remote_autostart=off\nxdebug.remote_enable=on\nxdebug.remote_port=9003\nxdebug.idekey=PHPSTORM\nxdebug.remote_connect_back=off\nxdebug.remote_log=/proc/self/fd/2\nxdebug.remote_host=host.docker.internal" > $PHP_INI_DIR/conf.d/docker-php-ext-xdebug.ini -ENTRYPOINT [ "/bin/bash", "-c", "tail -f /dev/null" ] - - - diff --git a/Makefile b/Makefile deleted file mode 100644 index ed2fe6f..0000000 --- a/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -.DEFAULT_GOAL := help - -help: ## Display this help - @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_\-0-9]+:.*?##/ { printf " \033[36m%-22s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) - -app-php56-dev-build: ## Create environment with php5.6 - docker compose up -d php56 - docker compose exec php56 composer update - -app-php71-dev-build: ## Create environment with php7.1 for unit tests - docker compose up -d php71 - docker compose exec php71 composer update - -run-tests-php56: app-php56-dev-build ## Runs unit tests with php5.6 - docker compose exec php56 vendor/bin/phpunit --configuration tests/phpunit.xml - -run-tests-php71: app-php71-dev-build ## Runs unit tests with php7.1 - docker compose exec php71 vendor/bin/phpunit --configuration tests/phpunit.xml - -deploy-to-github: ## Creates new release in github from gitlab tags - sh deploy.sh - -create-zip-dev: ## Creates zip file from current local files - sh create-zip-dev.sh \ No newline at end of file diff --git a/classes/WebserviceSpecificManagementGetresponseModule.php b/classes/WebserviceSpecificManagementGetresponseModule.php index 8947271..82cf452 100644 --- a/classes/WebserviceSpecificManagementGetresponseModule.php +++ b/classes/WebserviceSpecificManagementGetresponseModule.php @@ -17,6 +17,10 @@ * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + include_once _PS_MODULE_DIR_ . '/grprestashop/vendor/autoload.php'; use GetResponse\Configuration\Application\Command\UpsertConfiguration; @@ -188,7 +192,7 @@ private function getPluginDetails() return json_encode( [ - 'plugin_version' => '1.3.1', + 'plugin_version' => '1.5.0', 'prestashop_version' => _PS_VERSION_, 'php_version' => phpversion(), 'shops' => $shops, diff --git a/composer.json b/composer.json index 096eaab..74b4324 100755 --- a/composer.json +++ b/composer.json @@ -21,7 +21,8 @@ }, "require-dev": { "phpunit/phpunit": "^5.0", - "prestashop/php-dev-tools": "3.*" + "prestashop/php-dev-tools": "^3.16", + "phpstan/phpstan": "0.12.40" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index 3fcd732..3a6f313 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": "579a2c1a4fb429ae4b9e0bb13c463066", + "content-hash": "5b876e000e4bb615e872b438eeb1accb", "packages": [ { "name": "beberlei/assert", @@ -363,16 +363,16 @@ }, { "name": "doctrine/deprecations", - "version": "1.1.2", + "version": "1.1.3", "source": { "type": "git", "url": "https://github.com/doctrine/deprecations.git", - "reference": "4f2d4f2836e7ec4e7a8625e75c6aa916004db931" + "reference": "dfbaa3c2d2e9a9df1118213f3b8b0c597bb99fab" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/deprecations/zipball/4f2d4f2836e7ec4e7a8625e75c6aa916004db931", - "reference": "4f2d4f2836e7ec4e7a8625e75c6aa916004db931", + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/dfbaa3c2d2e9a9df1118213f3b8b0c597bb99fab", + "reference": "dfbaa3c2d2e9a9df1118213f3b8b0c597bb99fab", "shasum": "" }, "require": { @@ -404,9 +404,9 @@ "homepage": "https://www.doctrine-project.org/", "support": { "issues": "https://github.com/doctrine/deprecations/issues", - "source": "https://github.com/doctrine/deprecations/tree/1.1.2" + "source": "https://github.com/doctrine/deprecations/tree/1.1.3" }, - "time": "2023-09-27T20:04:15+00:00" + "time": "2024-01-30T19:34:25+00:00" }, { "name": "doctrine/instantiator", @@ -480,16 +480,16 @@ }, { "name": "doctrine/lexer", - "version": "2.1.0", + "version": "2.1.1", "source": { "type": "git", "url": "https://github.com/doctrine/lexer.git", - "reference": "39ab8fcf5a51ce4b85ca97c7a7d033eb12831124" + "reference": "861c870e8b75f7c8f69c146c7f89cc1c0f1b49b6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/lexer/zipball/39ab8fcf5a51ce4b85ca97c7a7d033eb12831124", - "reference": "39ab8fcf5a51ce4b85ca97c7a7d033eb12831124", + "url": "https://api.github.com/repos/doctrine/lexer/zipball/861c870e8b75f7c8f69c146c7f89cc1c0f1b49b6", + "reference": "861c870e8b75f7c8f69c146c7f89cc1c0f1b49b6", "shasum": "" }, "require": { @@ -497,11 +497,11 @@ "php": "^7.1 || ^8.0" }, "require-dev": { - "doctrine/coding-standard": "^9 || ^10", + "doctrine/coding-standard": "^9 || ^12", "phpstan/phpstan": "^1.3", - "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.6", "psalm/plugin-phpunit": "^0.18.3", - "vimeo/psalm": "^4.11 || ^5.0" + "vimeo/psalm": "^4.11 || ^5.21" }, "type": "library", "autoload": { @@ -538,7 +538,7 @@ ], "support": { "issues": "https://github.com/doctrine/lexer/issues", - "source": "https://github.com/doctrine/lexer/tree/2.1.0" + "source": "https://github.com/doctrine/lexer/tree/2.1.1" }, "funding": [ { @@ -554,7 +554,7 @@ "type": "tidelift" } ], - "time": "2022-12-14T08:49:07+00:00" + "time": "2024-02-05T11:35:39+00:00" }, { "name": "friendsofphp/php-cs-fixer", @@ -1062,6 +1062,66 @@ }, "time": "2020-03-05T15:02:03+00:00" }, + { + "name": "phpstan/phpstan", + "version": "0.12.40", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "dce7293ad7b59fc09a9ab9b0b5b44902c092ca17" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/dce7293ad7b59fc09a9ab9b0b5b44902c092ca17", + "reference": "dce7293ad7b59fc09a9ab9b0b5b44902c092ca17", + "shasum": "" + }, + "require": { + "php": "^7.1|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.12-dev" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "support": { + "issues": "https://github.com/phpstan/phpstan/issues", + "source": "https://github.com/phpstan/phpstan/tree/0.12.40" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://www.patreon.com/phpstan", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "type": "tidelift" + } + ], + "time": "2020-08-26T19:06:20+00:00" + }, { "name": "phpunit/php-code-coverage", "version": "4.0.8", @@ -2340,16 +2400,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.7.2", + "version": "3.9.0", "source": { "type": "git", - "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879" + "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", + "reference": "d63cee4890a8afaf86a22e51ad4d97c91dd4579b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/ed8e00df0a83aa96acf703f8c2979ff33341f879", - "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/d63cee4890a8afaf86a22e51ad4d97c91dd4579b", + "reference": "d63cee4890a8afaf86a22e51ad4d97c91dd4579b", "shasum": "" }, "require": { @@ -2359,11 +2419,11 @@ "php": ">=5.4.0" }, "require-dev": { - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4" }, "bin": [ - "bin/phpcs", - "bin/phpcbf" + "bin/phpcbf", + "bin/phpcs" ], "type": "library", "extra": { @@ -2378,22 +2438,45 @@ "authors": [ { "name": "Greg Sherwood", - "role": "lead" + "role": "Former lead" + }, + { + "name": "Juliette Reinders Folmer", + "role": "Current lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer/graphs/contributors" } ], "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", - "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer", "keywords": [ "phpcs", "standards", "static analysis" ], "support": { - "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", - "source": "https://github.com/squizlabs/PHP_CodeSniffer", - "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" + "issues": "https://github.com/PHPCSStandards/PHP_CodeSniffer/issues", + "security": "https://github.com/PHPCSStandards/PHP_CodeSniffer/security/policy", + "source": "https://github.com/PHPCSStandards/PHP_CodeSniffer", + "wiki": "https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki" }, - "time": "2023-02-22T23:07:41+00:00" + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + } + ], + "time": "2024-02-16T15:06:51+00:00" }, { "name": "symfony/console", @@ -2904,16 +2987,16 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.28.0", + "version": "v1.29.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb" + "reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb", - "reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ef4d7e442ca910c4764bce785146269b30cb5fc4", + "reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4", "shasum": "" }, "require": { @@ -2927,9 +3010,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -2966,7 +3046,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.29.0" }, "funding": [ { @@ -2982,20 +3062,20 @@ "type": "tidelift" } ], - "time": "2023-01-26T09:26:14+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.28.0", + "version": "v1.29.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "42292d99c55abe617799667f454222c54c60e229" + "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/42292d99c55abe617799667f454222c54c60e229", - "reference": "42292d99c55abe617799667f454222c54c60e229", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9773676c8a1bb1f8d4340a62efe641cf76eda7ec", + "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec", "shasum": "" }, "require": { @@ -3009,9 +3089,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -3049,7 +3126,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.29.0" }, "funding": [ { @@ -3065,7 +3142,7 @@ "type": "tidelift" } ], - "time": "2023-07-28T09:04:16+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { "name": "symfony/polyfill-php70", @@ -3137,16 +3214,16 @@ }, { "name": "symfony/polyfill-php72", - "version": "v1.28.0", + "version": "v1.29.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php72.git", - "reference": "70f4aebd92afca2f865444d30a4d2151c13c3179" + "reference": "861391a8da9a04cbad2d232ddd9e4893220d6e25" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/70f4aebd92afca2f865444d30a4d2151c13c3179", - "reference": "70f4aebd92afca2f865444d30a4d2151c13c3179", + "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/861391a8da9a04cbad2d232ddd9e4893220d6e25", + "reference": "861391a8da9a04cbad2d232ddd9e4893220d6e25", "shasum": "" }, "require": { @@ -3154,9 +3231,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -3193,7 +3267,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php72/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-php72/tree/v1.29.0" }, "funding": [ { @@ -3209,20 +3283,20 @@ "type": "tidelift" } ], - "time": "2023-01-26T09:26:14+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { "name": "symfony/polyfill-php80", - "version": "v1.28.0", + "version": "v1.29.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5" + "reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/6caa57379c4aec19c0a12a38b59b26487dcfe4b5", - "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/87b68208d5c1188808dd7839ee1e6c8ec3b02f1b", + "reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b", "shasum": "" }, "require": { @@ -3230,9 +3304,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -3276,7 +3347,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.28.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.29.0" }, "funding": [ { @@ -3292,7 +3363,7 @@ "type": "tidelift" } ], - "time": "2023-01-26T09:26:14+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { "name": "symfony/process", diff --git a/config.xml b/config.xml index d36ef48..0f56329 100644 --- a/config.xml +++ b/config.xml @@ -2,7 +2,7 @@ grprestashop - + diff --git a/controllers/admin/AdminGetresponseController.php b/controllers/admin/AdminGetresponseController.php index 8c40acb..e9358fe 100644 --- a/controllers/admin/AdminGetresponseController.php +++ b/controllers/admin/AdminGetresponseController.php @@ -17,6 +17,10 @@ * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + class AdminGetresponseController extends ModuleAdminController { public function __construct() diff --git a/controllers/front/CartRecovery.php b/controllers/front/CartRecovery.php new file mode 100644 index 0000000..7c48db8 --- /dev/null +++ b/controllers/front/CartRecovery.php @@ -0,0 +1,63 @@ + + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ + +use GetResponse\SharedKernel\CartRecoveryHelper; + +if (!defined('_PS_VERSION_')) { + exit; +} + +class GrPrestashopCartRecoveryModuleFrontController extends ModuleFrontController +{ + public function init() + { + $queryParams = Tools::getAllValues(); + + if (empty($queryParams['cart_id']) || empty($queryParams['cart_token'])) { + $this->showErrorFlashMessage(); + } + $cartId = $queryParams['cart_id']; + + if ($queryParams['cart_token'] != CartRecoveryHelper::generateCartToken($cartId)) { + $this->showErrorFlashMessage(); + } + + $recoveredCart = new Cart($cartId); + if (!Validate::isLoadedObject($recoveredCart)) { + $this->showErrorFlashMessage(); + } + + $this->context->cart = $recoveredCart; + $this->context->cookie->id_cart = (int) $recoveredCart->id; + + $link = $this->context->link ? $this->context->link : new Link(); + + $redirectLink = $link->getPageLink('cart', null, null, ['action' => 'show']); + Tools::redirect($redirectLink); + } + + private function showErrorFlashMessage() + { + $this->errors[] = $this->l('We could not recover your cart'); + $this->redirectWithNotifications('index.php'); + + return; + } +} diff --git a/tests/Unit/Configuration/index.php b/controllers/front/index.php similarity index 74% rename from tests/Unit/Configuration/index.php rename to controllers/front/index.php index 296d682..74851d7 100644 --- a/tests/Unit/Configuration/index.php +++ b/controllers/front/index.php @@ -17,12 +17,14 @@ * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); -header('Location: ../'); +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); exit; diff --git a/create-zip-dev.sh b/create-zip-dev.sh deleted file mode 100644 index 2e72c19..0000000 --- a/create-zip-dev.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/sh - -TMP_PATH="`pwd`/tmp" -RELEASE_DIR="grprestashop" -RELEASE_PATH="$TMP_PATH/$RELEASE_DIR" -RELEASE_FILE="grprestashop.zip" -COMPOSER_REMOTE_PROJECT_PATH="/plugin/tmp/$RELEASE_DIR" - -FILES_TO_DELETE=( - ".php_cs.dist" - "deploy.sh" - "create-zip-dev.sh" - ".gitlab-ci.yml" - "Dockerfile" - "docker-compose.yaml" - "Makefile" - ".env" - "tests" - "vendor" - "tmp" -) - -if [ -d "$TMP_PATH" ] -then - rm -rf $TMP_PATH -fi - -mkdir -p $TMP_PATH -mkdir -p $RELEASE_PATH - -echo "" -echo "Copy files" -cp -R * "$RELEASE_PATH" - -echo "" -echo "Remove unused files" -for file in ${FILES_TO_DELETE[@]} -do - rm -rf "$RELEASE_PATH/$file" -done - -echo "" -echo "Build composer" -docker compose exec php71 composer install --no-dev --working-dir="$COMPOSER_REMOTE_PROJECT_PATH" - -echo "" -echo "Create new zip" -cd $TMP_PATH && zip -rm "$RELEASE_FILE" "$RELEASE_DIR" -x ".git*" - -echo "ZIP done." \ No newline at end of file diff --git a/deploy.sh b/deploy.sh deleted file mode 100644 index e414c6c..0000000 --- a/deploy.sh +++ /dev/null @@ -1,140 +0,0 @@ -#!/bin/sh - -TMP_PATH="`pwd`/tmp" -GITLAB_REMOTE_URL="git@git.int.getresponse.com:integrations/prestashop/getresponse-for-prestashop.git" -GITHUB_REMOTE_URL="git@github.com:GetResponse/GetresponseForPrestashop.git" -GITHUB_PATH="$TMP_PATH/github" -RELEASE_DIR="grprestashop" -RELEASE_PATH="$TMP_PATH/$RELEASE_DIR" -RELEASE_FILE="grprestashop.zip" -COMPOSER_REMOTE_PROJECT_PATH="/plugin/tmp/$RELEASE_DIR" - -FILES_TO_DELETE=( - ".php_cs.dist" - "deploy.sh" - "create-zip-dev.sh" - ".gitlab-ci.yml" - "Dockerfile" - "docker-compose.yaml" - "Makefile" - ".env" -) - -if [ -d "$TMP_PATH" ] -then - rm -rf $TMP_PATH -fi - -mkdir -p $TMP_PATH -mkdir -p $RELEASE_PATH - -echo "--------------------------------------------" -echo " Gitlab to Github RELEASER " -echo "--------------------------------------------" -read -p "TAG AND RELEASE VERSION: " VERSION -echo "--------------------------------------------" -echo "" -echo "Before continuing, confirm that:" -echo "" -read -p " - Committed all changes up to Gitlab?" - -# validate version in grprestashop.php -PLUGIN_VERSION=`grep '$this->version =' grprestashop.php | awk -F"'" '{print $2}'` -if [ "$VERSION" != "$PLUGIN_VERSION" ] -then - echo "Version: $VERSION not found in grprestashop.php file" - exit 1 -fi - -# validate version in CHANGELOG.md -if ! grep -q "## \[$VERSION\]" CHANGELOG.md; then - echo "Version: $VERSION not found in CHANGELOG.md file" - exit 1 -fi - -# validate version in webservice file -PLUGIN_VERSION=`grep "'plugin_version' => " classes/WebserviceSpecificManagementGetresponseModule.php | awk -F"'" '{print $4}'` -if [ "$VERSION" != "$PLUGIN_VERSION" ] -then - echo "Version: $VERSION not found in WebserviceSpecificManagementGetresponseModule.php file" - exit 1 -fi - -# validate version in config.xml -PLUGIN_VERSION=$(grep '' config.xml | sed -n 's/.*<\/version>.*/\1/p') -echo $PLUGIN_VERSION; -if [ "$VERSION" != "$PLUGIN_VERSION" ] -then - echo "Version: $VERSION not found in config.xml file" - exit 1 -fi - -# validate if tag exists in GitLab -git ls-remote --exit-code --tags origin $VERSION >/dev/null 2>&1 -if ! [ $? == 0 ] -then - echo "Tag $VERSION in GitLab not found" - exit 1 -fi - -read -p "PRESS [ENTER] TO BEGIN RELEASING "$VERSION -clear - -if ! [ -d "$GITHUB_PATH" ] -then - echo "Clone Github repository... this may take a while" - git clone $GITHUB_REMOTE_URL $GITHUB_PATH -fi - -echo "" -echo "Copy files" -git fetch --all --tags -git archive --remote="$GITLAB_REMOTE_URL" tags/"$VERSION" | tar -x -C "$GITHUB_PATH" - -echo "" -echo "Remove unused files" -for file in ${FILES_TO_DELETE[@]} -do - rm -rf "$GITHUB_PATH/$file" -done - -echo "" -echo "" -echo "----------------" -echo "Github status:" -cd $GITHUB_PATH && git status - -echo "" -read -p "Press [ENTER] to commit release $VERSION to Github" - -echo "" -echo "Committing to Github... this may take a while" -cd $GITHUB_PATH && git add -A && git commit -a -m "Release $VERSION" && git push || { echo "Unable to commit."; exit 1; } - -echo "" -echo "Create new directory for module" -git archive --remote="$GITLAB_REMOTE_URL" tags/"$VERSION" | (cd "$RELEASE_PATH" && tar xf -) - -for file in ${FILES_TO_DELETE[@]} -do - rm -rf "$RELEASE_PATH/$file" -done - -echo "" -echo "Build composer" -docker compose exec php71 composer install --no-dev --working-dir="$COMPOSER_REMOTE_PROJECT_PATH" - -cp "$RELEASE_PATH/tests/index.php $RELEASE_PATH/vendor/index.php" - -echo "" -echo "Create new release" -cd $TMP_PATH && zip -rm "$RELEASE_FILE" "$RELEASE_DIR" -x ".git*" - -cd $GITHUB_PATH && gh release create "$VERSION" --generate-notes --latest -n "$VERSION" "$TMP_PATH/$RELEASE_FILE" - -echo "" -echo "Remove temporary files" -rm -rf "$TMP_PATH" - -echo "" -echo "Release done." \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml deleted file mode 100644 index c062239..0000000 --- a/docker-compose.yaml +++ /dev/null @@ -1,13 +0,0 @@ -services: - php71: - build: - context: . - target: php7 - volumes: - - ./:/plugin:consistent - php56: - build: - context: . - target: php5 - volumes: - - ./:/plugin:consistent diff --git a/grprestashop.php b/grprestashop.php index 6c8c3e5..daa2ff7 100755 --- a/grprestashop.php +++ b/grprestashop.php @@ -1,6 +1,6 @@ * @copyright GetResponse @@ -42,11 +42,11 @@ public function __construct() { $this->name = 'grprestashop'; $this->tab = 'emailing'; - $this->version = '1.3.1'; + $this->version = '1.5.0'; $this->author = 'GetResponse'; $this->need_instance = 0; $this->module_key = '311ef191c3135b237511d18c4bc27369'; - $this->ps_versions_compliancy = ['min' => '1.6', 'max' => _PS_VERSION_]; + $this->ps_versions_compliancy = ['min' => '1.6', 'max' => '8.1.7']; $this->displayName = $this->l('GetResponse'); $this->description = 'Add your Prestashop contacts to GetResponse.'; $this->confirmUninstall = $this->l('Are you sure you want to uninstall?'); @@ -83,70 +83,70 @@ public function hookAddWebserviceResources() public function hookDisplayHome() { $currentShopId = $this->context->shop->id; - $configurationReadModel = new \GetResponse\Configuration\ReadModel\ConfigurationReadModel( - new \GetResponse\Configuration\Infrastructure\ConfigurationRepository() + $configurationReadModel = new GetResponse\Configuration\ReadModel\ConfigurationReadModel( + new GetResponse\Configuration\Infrastructure\ConfigurationRepository() ); $configuration = $configurationReadModel->getConfigurationForShop($currentShopId); return $this->getGrWebFormSnippet( $configuration, - \GetResponse\Configuration\SharedKernel\WebFormPosition::HOME + GetResponse\Configuration\SharedKernel\WebFormPosition::HOME ); } public function hookDisplayTop() { $currentShopId = $this->context->shop->id; - $configurationReadModel = new \GetResponse\Configuration\ReadModel\ConfigurationReadModel( - new \GetResponse\Configuration\Infrastructure\ConfigurationRepository() + $configurationReadModel = new GetResponse\Configuration\ReadModel\ConfigurationReadModel( + new GetResponse\Configuration\Infrastructure\ConfigurationRepository() ); $configuration = $configurationReadModel->getConfigurationForShop($currentShopId); return $this->getGrWebFormSnippet( $configuration, - \GetResponse\Configuration\SharedKernel\WebFormPosition::TOP + GetResponse\Configuration\SharedKernel\WebFormPosition::TOP ); } public function hookDisplayLeftColumn() { $currentShopId = $this->context->shop->id; - $configurationReadModel = new \GetResponse\Configuration\ReadModel\ConfigurationReadModel( - new \GetResponse\Configuration\Infrastructure\ConfigurationRepository() + $configurationReadModel = new GetResponse\Configuration\ReadModel\ConfigurationReadModel( + new GetResponse\Configuration\Infrastructure\ConfigurationRepository() ); $configuration = $configurationReadModel->getConfigurationForShop($currentShopId); return $this->getGrWebFormSnippet( $configuration, - \GetResponse\Configuration\SharedKernel\WebFormPosition::LEFT + GetResponse\Configuration\SharedKernel\WebFormPosition::LEFT ); } public function hookDisplayRightColumn() { $currentShopId = $this->context->shop->id; - $configurationReadModel = new \GetResponse\Configuration\ReadModel\ConfigurationReadModel( - new \GetResponse\Configuration\Infrastructure\ConfigurationRepository() + $configurationReadModel = new GetResponse\Configuration\ReadModel\ConfigurationReadModel( + new GetResponse\Configuration\Infrastructure\ConfigurationRepository() ); $configuration = $configurationReadModel->getConfigurationForShop($currentShopId); return $this->getGrWebFormSnippet( $configuration, - \GetResponse\Configuration\SharedKernel\WebFormPosition::RIGHT + GetResponse\Configuration\SharedKernel\WebFormPosition::RIGHT ); } public function hookDisplayFooter() { $currentShopId = $this->context->shop->id; - $configurationReadModel = new \GetResponse\Configuration\ReadModel\ConfigurationReadModel( - new \GetResponse\Configuration\Infrastructure\ConfigurationRepository() + $configurationReadModel = new GetResponse\Configuration\ReadModel\ConfigurationReadModel( + new GetResponse\Configuration\Infrastructure\ConfigurationRepository() ); $configuration = $configurationReadModel->getConfigurationForShop($currentShopId); return $this->getGrWebFormSnippet( $configuration, - \GetResponse\Configuration\SharedKernel\WebFormPosition::FOOTER + GetResponse\Configuration\SharedKernel\WebFormPosition::FOOTER ); } @@ -161,8 +161,8 @@ public function hookDisplayBackOfficeHeader() public function hookDisplayHeader() { $currentShopId = $this->context->shop->id; - $configurationReadModel = new \GetResponse\Configuration\ReadModel\ConfigurationReadModel( - new \GetResponse\Configuration\Infrastructure\ConfigurationRepository() + $configurationReadModel = new GetResponse\Configuration\ReadModel\ConfigurationReadModel( + new GetResponse\Configuration\Infrastructure\ConfigurationRepository() ); $configuration = $configurationReadModel->getConfigurationForShop($currentShopId); @@ -175,24 +175,24 @@ public function hookDisplayHeader() $getresponseShopId = $configuration->getGetresponseShopId(); if ($_SERVER['REQUEST_METHOD'] === 'GET') { - $storage = new \GetResponse\SharedKernel\SessionStorage(); - $session = new \GetResponse\TrackingCode\DomainModel\TrackingCodeBufferService($storage); - $cartService = new \GetResponse\TrackingCode\Application\CartService($configurationReadModel, $session); + $sessionStorage = new \GetResponse\SharedKernel\Session\StorageFactory(); + $storage = $sessionStorage->create(); + $session = new GetResponse\TrackingCode\DomainModel\TrackingCodeBufferService($storage); + $cartService = new GetResponse\TrackingCode\Application\CartService($configurationReadModel, $session); $cart = $cartService->getCartFromBuffer($currentShopId); if (null !== $cart) { - $cartPresenter = new \GetResponse\TrackingCode\Presenter\CartPresenter($cart); + $cartPresenter = new GetResponse\TrackingCode\Presenter\CartPresenter($cart); $this->smarty->assign('buffered_cart', json_encode($cartPresenter->present())); } if (isset($this->context->controller->php_self) && $this->context->controller->php_self === 'order-confirmation') { - $orderService = new \GetResponse\TrackingCode\Application\OrderService($configurationReadModel, $session); + $orderService = new GetResponse\TrackingCode\Application\OrderService($configurationReadModel, $session); $order = $orderService->getOrderFromBuffer($currentShopId); if (null !== $order) { - - $orderPresenter = new \GetResponse\TrackingCode\Presenter\OrderPresenter($order); + $orderPresenter = new GetResponse\TrackingCode\Presenter\OrderPresenter($order); $this->smarty->assign('buffered_order', json_encode($orderPresenter->present())); } } @@ -226,8 +226,8 @@ public function hookDisplayHeader() */ public function getContent() { - $configurationReadModel = new \GetResponse\Configuration\ReadModel\ConfigurationReadModel( - new \GetResponse\Configuration\Infrastructure\ConfigurationRepository() + $configurationReadModel = new GetResponse\Configuration\ReadModel\ConfigurationReadModel( + new GetResponse\Configuration\Infrastructure\ConfigurationRepository() ); $context = Context::getContext(); @@ -266,6 +266,7 @@ public function getContent() /** * @return bool + * * @throws PrestaShopDatabaseException * @throws PrestaShopException */ @@ -311,6 +312,7 @@ public function installTab() /** * @return bool + * * @throws PrestaShopDatabaseException * @throws PrestaShopException */ @@ -326,8 +328,8 @@ public function uninstall() } } - $configurationService = new \GetResponse\Configuration\Application\ConfigurationService( - new \GetResponse\Configuration\Infrastructure\ConfigurationRepository() + $configurationService = new GetResponse\Configuration\Application\ConfigurationService( + new GetResponse\Configuration\Infrastructure\ConfigurationRepository() ); $configurationService->deleteAllConfigurations(); @@ -340,6 +342,7 @@ public function uninstall() /** * @return bool + * * @throws PrestaShopDatabaseException * @throws PrestaShopException */ @@ -359,24 +362,24 @@ public function hookActionNewsletterRegistrationAfter($params) { try { $email = $params['email']; - $name = $params['name'] ?? null; + $name = isset($_POST['name']) ? $_POST['name'] : null; if (null !== $email) { $shop = new Shop($this->context->shop->id); - $contactService = new \GetResponse\Contact\Application\ContactService( - new \GetResponse\MessageSender\Application\MessageSenderService( - new \GetResponse\MessageSender\Infrastructure\HttpClient($shop->getBaseURL()) + $contactService = new GetResponse\Contact\Application\ContactService( + new GetResponse\MessageSender\Application\MessageSenderService( + new GetResponse\MessageSender\Infrastructure\HttpClient($shop->getBaseURL()) ), - new \GetResponse\Configuration\ReadModel\ConfigurationReadModel( - new \GetResponse\Configuration\Infrastructure\ConfigurationRepository() + new GetResponse\Configuration\ReadModel\ConfigurationReadModel( + new GetResponse\Configuration\Infrastructure\ConfigurationRepository() ) ); $contactService->upsertSubscriber( - new \GetResponse\Contact\Application\Command\UpsertSubscriber($email, true, $shop->id, $name) + new GetResponse\Contact\Application\Command\UpsertSubscriber($email, true, $shop->id, $name) ); } - } catch (\GetResponse\MessageSender\Application\MessageSenderException $e) { + } catch (GetResponse\MessageSender\Application\MessageSenderException $e) { $this->logGetResponseError($e->getMessage()); } } @@ -390,7 +393,7 @@ public function hookActionObjectCustomerUpdateAfter($params) if (null !== $customer) { $this->upsertCustomer($customer); } - } catch (\GetResponse\MessageSender\Application\MessageSenderException $e) { + } catch (GetResponse\MessageSender\Application\MessageSenderException $e) { $this->logGetResponseError($e->getMessage()); } } @@ -404,7 +407,7 @@ public function hookActionCustomerAccountAdd($params) if (null !== $customer) { $this->upsertCustomer($customer); } - } catch (\GetResponse\MessageSender\Application\MessageSenderException $e) { + } catch (GetResponse\MessageSender\Application\MessageSenderException $e) { $this->logGetResponseError($e->getMessage()); } } @@ -426,26 +429,26 @@ public function hookActionCartSave($params) $shop = new Shop($cart->id_shop); - $configurationReadModel = new \GetResponse\Configuration\ReadModel\ConfigurationReadModel( - new \GetResponse\Configuration\Infrastructure\ConfigurationRepository() + $configurationReadModel = new GetResponse\Configuration\ReadModel\ConfigurationReadModel( + new GetResponse\Configuration\Infrastructure\ConfigurationRepository() ); - $cartService = new \GetResponse\Ecommerce\Application\CartService( - new \GetResponse\MessageSender\Application\MessageSenderService( - new \GetResponse\MessageSender\Infrastructure\HttpClient($shop->getBaseURL()) + $cartService = new GetResponse\Ecommerce\Application\CartService( + new GetResponse\MessageSender\Application\MessageSenderService( + new GetResponse\MessageSender\Infrastructure\HttpClient($shop->getBaseURL()) ), $configurationReadModel ); - $cartService->upsertCart(new \GetResponse\Ecommerce\Application\Command\UpsertCart($cart->id, $shop->id)); + $cartService->upsertCart(new GetResponse\Ecommerce\Application\Command\UpsertCart($cart->id, $shop->id)); - $sessionStorage = new \GetResponse\SharedKernel\SessionStorage(); - $trackingCodeCartService = new \GetResponse\TrackingCode\Application\CartService( + $sessionStorage = new \GetResponse\SharedKernel\Session\StorageFactory(); + $storage = $sessionStorage->create(); + $trackingCodeCartService = new GetResponse\TrackingCode\Application\CartService( $configurationReadModel, - new \GetResponse\TrackingCode\DomainModel\TrackingCodeBufferService($sessionStorage) + new GetResponse\TrackingCode\DomainModel\TrackingCodeBufferService($storage) ); $trackingCodeCartService->addCartToBuffer($cart->id, $shop->id); - - } catch (\GetResponse\MessageSender\Application\MessageSenderException $e) { + } catch (GetResponse\MessageSender\Application\MessageSenderException $e) { $this->logGetResponseError($e->getMessage()); } } @@ -459,7 +462,7 @@ public function hookActionObjectAddressUpdateAfter($params) if (null !== $address && null !== $address->id_customer) { $this->upsertCustomer(new Customer($address->id_customer)); } - } catch (\GetResponse\MessageSender\Application\MessageSenderException $e) { + } catch (GetResponse\MessageSender\Application\MessageSenderException $e) { $this->logGetResponseError($e->getMessage()); } } @@ -473,7 +476,7 @@ public function hookActionObjectAddressAddAfter($params) if (null !== $address && null !== $address->id_customer) { $this->upsertCustomer(new Customer($address->id_customer)); } - } catch (\GetResponse\MessageSender\Application\MessageSenderException $e) { + } catch (GetResponse\MessageSender\Application\MessageSenderException $e) { $this->logGetResponseError($e->getMessage()); } } @@ -487,7 +490,7 @@ public function hookActionProductAdd($params) if (null !== $product) { $this->upsertProduct($product); } - } catch (\GetResponse\MessageSender\Application\MessageSenderException $e) { + } catch (GetResponse\MessageSender\Application\MessageSenderException $e) { $this->logGetResponseError($e->getMessage()); } } @@ -495,13 +498,15 @@ public function hookActionProductAdd($params) public function hookActionProductUpdate($params) { try { - /** @var Product $product */ - $product = $params['product']; - - if (null !== $product) { - $this->upsertProduct($product); + if(isset($params['product'])){ + /** @var Product $product */ + $product = $params['product']; + + if (null !== $product) { + $this->upsertProduct($product); + } } - } catch (\GetResponse\MessageSender\Application\MessageSenderException $e) { + } catch (GetResponse\MessageSender\Application\MessageSenderException $e) { $this->logGetResponseError($e->getMessage()); } } @@ -517,9 +522,9 @@ public function hookActionOrderStatusUpdate($params) } $this->upsertOrder($order); - } catch (\GetResponse\MessageSender\Application\MessageSenderException $e) { + } catch (GetResponse\MessageSender\Application\MessageSenderException $e) { $this->logGetResponseError($e->getMessage()); - } catch (\Exception $e) { + } catch (Exception $e) { $this->logGetResponseError($e->getMessage()); } } @@ -534,9 +539,9 @@ public function hookActionOrderStatusPostUpdate($params) $order = new Order($params['id_order']); $this->upsertOrder($order); - } catch (\GetResponse\MessageSender\Application\MessageSenderException $e) { + } catch (GetResponse\MessageSender\Application\MessageSenderException $e) { $this->logGetResponseError($e->getMessage()); - } catch (\Exception $e) { + } catch (Exception $e) { $this->logGetResponseError($e->getMessage()); } } @@ -552,9 +557,9 @@ public function hookActionOrderEdited($params) } $this->upsertOrder($order); - } catch (\GetResponse\MessageSender\Application\MessageSenderException $e) { + } catch (GetResponse\MessageSender\Application\MessageSenderException $e) { $this->logGetResponseError($e->getMessage()); - } catch (\Exception $e) { + } catch (Exception $e) { $this->logGetResponseError($e->getMessage()); } } @@ -568,7 +573,7 @@ private function logGetResponseError($message) } /** - * @param \GetResponse\Configuration\ReadModel\ConfigurationDto $configuration + * @param GetResponse\Configuration\ReadModel\ConfigurationDto $configuration * @param string $position * * @return false|string|null @@ -591,52 +596,54 @@ private function getGrWebFormSnippet($configuration, $position) /** * @param Customer $customer - * @throws \GetResponse\MessageSender\Application\MessageSenderException + * + * @throws GetResponse\MessageSender\Application\MessageSenderException */ private function upsertCustomer(Customer $customer) { $shop = new Shop($customer->id_shop); - $contactService = new \GetResponse\Contact\Application\ContactService( - new \GetResponse\MessageSender\Application\MessageSenderService( - new \GetResponse\MessageSender\Infrastructure\HttpClient($shop->getBaseURL()) + $contactService = new GetResponse\Contact\Application\ContactService( + new GetResponse\MessageSender\Application\MessageSenderService( + new GetResponse\MessageSender\Infrastructure\HttpClient($shop->getBaseURL()) ), - new \GetResponse\Configuration\ReadModel\ConfigurationReadModel( - new \GetResponse\Configuration\Infrastructure\ConfigurationRepository() + new GetResponse\Configuration\ReadModel\ConfigurationReadModel( + new GetResponse\Configuration\Infrastructure\ConfigurationRepository() ) ); $contactService->upsertCustomer( - new \GetResponse\Contact\Application\Command\UpsertCustomer($customer->id, $shop->id) + new GetResponse\Contact\Application\Command\UpsertCustomer($customer->id, $shop->id) ); } /** * @param Product $product - * @throws \GetResponse\MessageSender\Application\MessageSenderException + * + * @throws GetResponse\MessageSender\Application\MessageSenderException */ private function upsertProduct(Product $product) { - if (null === \ShopCore::getContextShopID()) { + if (null === ShopCore::getContextShopID()) { return; } - $languageId = \Configuration::get('PS_LANG_DEFAULT'); + $languageId = Configuration::get('PS_LANG_DEFAULT'); $shops = $product->getAssociatedShops(); foreach ($shops as $shopId) { - $shop = new \Shop($shopId); + $shop = new Shop($shopId); - $productService = new \GetResponse\Ecommerce\Application\ProductService( - new \GetResponse\MessageSender\Application\MessageSenderService( - new \GetResponse\MessageSender\Infrastructure\HttpClient($shop->getBaseURL()) + $productService = new GetResponse\Ecommerce\Application\ProductService( + new GetResponse\MessageSender\Application\MessageSenderService( + new GetResponse\MessageSender\Infrastructure\HttpClient($shop->getBaseURL()) ), - new \GetResponse\Configuration\ReadModel\ConfigurationReadModel( - new \GetResponse\Configuration\Infrastructure\ConfigurationRepository() + new GetResponse\Configuration\ReadModel\ConfigurationReadModel( + new GetResponse\Configuration\Infrastructure\ConfigurationRepository() ) ); $productService->upsertProduct( - new \GetResponse\Ecommerce\Application\Command\UpsertProduct( + new GetResponse\Ecommerce\Application\Command\UpsertProduct( (int) $shopId, $product->id, (int) $languageId @@ -647,31 +654,33 @@ private function upsertProduct(Product $product) /** * @param Order $order - * @throws \GetResponse\MessageSender\Application\MessageSenderException + * + * @throws GetResponse\MessageSender\Application\MessageSenderException */ private function upsertOrder(Order $order) { - $shop = new \Shop($order->id_shop); - $configurationReadModel = new \GetResponse\Configuration\ReadModel\ConfigurationReadModel( - new \GetResponse\Configuration\Infrastructure\ConfigurationRepository() + $shop = new Shop($order->id_shop); + $configurationReadModel = new GetResponse\Configuration\ReadModel\ConfigurationReadModel( + new GetResponse\Configuration\Infrastructure\ConfigurationRepository() ); $orderService = new GetResponse\Ecommerce\Application\OrderService( - new \GetResponse\MessageSender\Application\MessageSenderService( - new \GetResponse\MessageSender\Infrastructure\HttpClient($shop->getBaseURL()) + new GetResponse\MessageSender\Application\MessageSenderService( + new GetResponse\MessageSender\Infrastructure\HttpClient($shop->getBaseURL()) ), $configurationReadModel ); $orderService->upsertOrder( - new \GetResponse\Ecommerce\Application\Command\UpsertOrder($order->id, $order->id_shop) + new GetResponse\Ecommerce\Application\Command\UpsertOrder($order->id, $order->id_shop) ); - $sessionStorage = new \GetResponse\SharedKernel\SessionStorage(); + $sessionStorage = new \GetResponse\SharedKernel\Session\StorageFactory(); + $storage = $sessionStorage->create(); - $trackingCodeOrderService = new \GetResponse\TrackingCode\Application\OrderService( + $trackingCodeOrderService = new GetResponse\TrackingCode\Application\OrderService( $configurationReadModel, - new \GetResponse\TrackingCode\DomainModel\TrackingCodeBufferService($sessionStorage) + new GetResponse\TrackingCode\DomainModel\TrackingCodeBufferService($storage) ); $trackingCodeOrderService->addOrderToBuffer($order->id, $order->id_shop); @@ -679,8 +688,8 @@ private function upsertOrder(Order $order) private function assignRecommendationObject($recommendationSnippet) { - $service = new \GetResponse\Ecommerce\Application\RecommendationService( - new \GetResponse\Ecommerce\Application\Adapter\ProductAdapter() + $service = new GetResponse\Ecommerce\Application\RecommendationService( + new GetResponse\Ecommerce\Application\Adapter\ProductAdapter() ); $pageType = $service->getPageType($this->context->controller->php_self); @@ -693,7 +702,7 @@ private function assignRecommendationObject($recommendationSnippet) $pageData = []; if ($pageType === 'product') { - $command = new \GetResponse\Ecommerce\Application\Command\RecommendedProductCommand( + $command = new GetResponse\Ecommerce\Application\Command\RecommendedProductCommand( Tools::getValue('id_product'), Configuration::get('PS_LANG_DEFAULT') ); diff --git a/override/classes/webservice/WebserviceRequest.php b/override/classes/webservice/WebserviceRequest.php index 5cafed0..8af28cd 100644 --- a/override/classes/webservice/WebserviceRequest.php +++ b/override/classes/webservice/WebserviceRequest.php @@ -17,6 +17,10 @@ * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ +if (!defined('_PS_VERSION_')) { + exit; +} + class WebserviceRequest extends WebserviceRequestCore { public function __construct() diff --git a/src/Configuration/Application/Command/UpsertConfiguration.php b/src/Configuration/Application/Command/UpsertConfiguration.php index d0818cc..2eae688 100644 --- a/src/Configuration/Application/Command/UpsertConfiguration.php +++ b/src/Configuration/Application/Command/UpsertConfiguration.php @@ -20,6 +20,10 @@ namespace GetResponse\Configuration\Application\Command; +if (!defined('_PS_VERSION_')) { + exit; +} + class UpsertConfiguration { /** @var int */ diff --git a/src/Configuration/Application/ConfigurationService.php b/src/Configuration/Application/ConfigurationService.php index 968014f..132be97 100644 --- a/src/Configuration/Application/ConfigurationService.php +++ b/src/Configuration/Application/ConfigurationService.php @@ -25,6 +25,10 @@ use GetResponse\Configuration\Domain\LiveSynchronization; use GetResponse\Configuration\Domain\WebForm; +if (!defined('_PS_VERSION_')) { + exit; +} + class ConfigurationService { private $configurationRepository; diff --git a/src/Configuration/Domain/Configuration.php b/src/Configuration/Domain/Configuration.php index d678b42..b654c29 100644 --- a/src/Configuration/Domain/Configuration.php +++ b/src/Configuration/Domain/Configuration.php @@ -20,6 +20,10 @@ namespace GetResponse\Configuration\Domain; +if (!defined('_PS_VERSION_')) { + exit; +} + class Configuration { /** @var int */ diff --git a/src/Configuration/Domain/ConfigurationRepository.php b/src/Configuration/Domain/ConfigurationRepository.php index e01a8f7..54db4dc 100644 --- a/src/Configuration/Domain/ConfigurationRepository.php +++ b/src/Configuration/Domain/ConfigurationRepository.php @@ -20,6 +20,9 @@ namespace GetResponse\Configuration\Domain; +if (!defined('_PS_VERSION_')) { + exit; +} interface ConfigurationRepository { /** diff --git a/src/Configuration/Domain/LiveSynchronization.php b/src/Configuration/Domain/LiveSynchronization.php index f90a5d1..bcf2fec 100644 --- a/src/Configuration/Domain/LiveSynchronization.php +++ b/src/Configuration/Domain/LiveSynchronization.php @@ -22,6 +22,10 @@ use Assert\Assertion; +if (!defined('_PS_VERSION_')) { + exit; +} + class LiveSynchronization { /** @var string */ diff --git a/src/Configuration/Domain/WebForm.php b/src/Configuration/Domain/WebForm.php index 7863539..81612d8 100644 --- a/src/Configuration/Domain/WebForm.php +++ b/src/Configuration/Domain/WebForm.php @@ -23,6 +23,10 @@ use Assert\Assertion; use GetResponse\Configuration\SharedKernel\WebFormPosition; +if (!defined('_PS_VERSION_')) { + exit; +} + class WebForm { /** @var string */ diff --git a/src/Configuration/Infrastructure/ConfigurationRepository.php b/src/Configuration/Infrastructure/ConfigurationRepository.php index aa5004d..a4ebf4e 100644 --- a/src/Configuration/Infrastructure/ConfigurationRepository.php +++ b/src/Configuration/Infrastructure/ConfigurationRepository.php @@ -24,6 +24,10 @@ use GetResponse\Configuration\Domain\ConfigurationRepository as Repository; use GetResponse\Configuration\ReadModel\ConfigurationDto; +if (!defined('_PS_VERSION_')) { + exit; +} + class ConfigurationRepository implements Repository { const FB_PIXEL_SNIPPET = 'GR_CONFIG_FB_PIXEL_SNIPPET'; diff --git a/src/Configuration/ReadModel/ConfigurationDto.php b/src/Configuration/ReadModel/ConfigurationDto.php index d1baa7f..1cb9661 100644 --- a/src/Configuration/ReadModel/ConfigurationDto.php +++ b/src/Configuration/ReadModel/ConfigurationDto.php @@ -20,6 +20,10 @@ namespace GetResponse\Configuration\ReadModel; +if (!defined('_PS_VERSION_')) { + exit; +} + class ConfigurationDto { /** @var int */ diff --git a/src/Configuration/ReadModel/ConfigurationDtoCollection.php b/src/Configuration/ReadModel/ConfigurationDtoCollection.php index 5b0b2e4..3e5e2a8 100644 --- a/src/Configuration/ReadModel/ConfigurationDtoCollection.php +++ b/src/Configuration/ReadModel/ConfigurationDtoCollection.php @@ -20,6 +20,10 @@ namespace GetResponse\Configuration\ReadModel; +if (!defined('_PS_VERSION_')) { + exit; +} + class ConfigurationDtoCollection implements \IteratorAggregate { private $configurations; diff --git a/src/Configuration/ReadModel/ConfigurationReadModel.php b/src/Configuration/ReadModel/ConfigurationReadModel.php index f3400c1..dc2f145 100644 --- a/src/Configuration/ReadModel/ConfigurationReadModel.php +++ b/src/Configuration/ReadModel/ConfigurationReadModel.php @@ -22,6 +22,10 @@ use GetResponse\Configuration\Infrastructure\ConfigurationRepository; +if (!defined('_PS_VERSION_')) { + exit; +} + class ConfigurationReadModel { /** @var ConfigurationRepository */ diff --git a/src/Configuration/SharedKernel/WebFormPosition.php b/src/Configuration/SharedKernel/WebFormPosition.php index c8dbdc2..e9c5cdc 100644 --- a/src/Configuration/SharedKernel/WebFormPosition.php +++ b/src/Configuration/SharedKernel/WebFormPosition.php @@ -20,6 +20,10 @@ namespace GetResponse\Configuration\SharedKernel; +if (!defined('_PS_VERSION_')) { + exit; +} + class WebFormPosition { const FOOTER = 'footer'; diff --git a/src/Contact/Application/Adapter/CustomerAdapter.php b/src/Contact/Application/Adapter/CustomerAdapter.php index de00a7e..b552676 100644 --- a/src/Contact/Application/Adapter/CustomerAdapter.php +++ b/src/Contact/Application/Adapter/CustomerAdapter.php @@ -24,6 +24,10 @@ use GetResponse\Contact\DomainModel\Customer; use GetResponse\Ecommerce\DomainModel\Address; +if (!defined('_PS_VERSION_')) { + exit; +} + class CustomerAdapter { /** diff --git a/src/Contact/Application/Command/UnsubscribeContact.php b/src/Contact/Application/Command/UnsubscribeContact.php index e893f28..dff8464 100644 --- a/src/Contact/Application/Command/UnsubscribeContact.php +++ b/src/Contact/Application/Command/UnsubscribeContact.php @@ -20,6 +20,10 @@ namespace GetResponse\Contact\Application\Command; +if (!defined('_PS_VERSION_')) { + exit; +} + class UnsubscribeContact { /** @var int */ diff --git a/src/Contact/Application/Command/UpsertCustomer.php b/src/Contact/Application/Command/UpsertCustomer.php index 48f7481..208259d 100644 --- a/src/Contact/Application/Command/UpsertCustomer.php +++ b/src/Contact/Application/Command/UpsertCustomer.php @@ -20,6 +20,10 @@ namespace GetResponse\Contact\Application\Command; +if (!defined('_PS_VERSION_')) { + exit; +} + class UpsertCustomer { /** @var int */ diff --git a/src/Contact/Application/Command/UpsertSubscriber.php b/src/Contact/Application/Command/UpsertSubscriber.php index 6d09da3..a034610 100644 --- a/src/Contact/Application/Command/UpsertSubscriber.php +++ b/src/Contact/Application/Command/UpsertSubscriber.php @@ -20,6 +20,10 @@ namespace GetResponse\Contact\Application\Command; +if (!defined('_PS_VERSION_')) { + exit; +} + class UpsertSubscriber { /** @var int */ diff --git a/src/Contact/Application/ContactService.php b/src/Contact/Application/ContactService.php index df7f033..c01720c 100644 --- a/src/Contact/Application/ContactService.php +++ b/src/Contact/Application/ContactService.php @@ -28,6 +28,10 @@ use GetResponse\MessageSender\Application\MessageSenderException; use GetResponse\MessageSender\Application\MessageSenderService; +if (!defined('_PS_VERSION_')) { + exit; +} + class ContactService { /** @var MessageSenderService */ diff --git a/src/Contact/Application/SubscriberService.php b/src/Contact/Application/SubscriberService.php index 56b161a..be7ca8e 100644 --- a/src/Contact/Application/SubscriberService.php +++ b/src/Contact/Application/SubscriberService.php @@ -23,6 +23,10 @@ use GetResponse\Contact\Application\Command\UnsubscribeContact; use GetResponse\Contact\DomainModel\NewsletterRepository; +if (!defined('_PS_VERSION_')) { + exit; +} + class SubscriberService { /** @var NewsletterRepository */ diff --git a/src/Contact/DomainModel/Customer.php b/src/Contact/DomainModel/Customer.php index 510f984..d911eee 100644 --- a/src/Contact/DomainModel/Customer.php +++ b/src/Contact/DomainModel/Customer.php @@ -23,6 +23,10 @@ use GetResponse\Ecommerce\DomainModel\Address; use GetResponse\SharedKernel\CallbackType; +if (!defined('_PS_VERSION_')) { + exit; +} + class Customer implements \JsonSerializable { /** @var int */ diff --git a/src/Contact/DomainModel/NewsletterRepository.php b/src/Contact/DomainModel/NewsletterRepository.php index 63be4f3..fc586ad 100644 --- a/src/Contact/DomainModel/NewsletterRepository.php +++ b/src/Contact/DomainModel/NewsletterRepository.php @@ -20,6 +20,9 @@ namespace GetResponse\Contact\DomainModel; +if (!defined('_PS_VERSION_')) { + exit; +} interface NewsletterRepository { /** diff --git a/src/Contact/DomainModel/Subscriber.php b/src/Contact/DomainModel/Subscriber.php index 4f194a3..7c787eb 100644 --- a/src/Contact/DomainModel/Subscriber.php +++ b/src/Contact/DomainModel/Subscriber.php @@ -21,6 +21,11 @@ namespace GetResponse\Contact\DomainModel; use GetResponse\SharedKernel\CallbackType; + +if (!defined('_PS_VERSION_')) { + exit; +} + class Subscriber implements \JsonSerializable { /** @var string */ diff --git a/src/Contact/Infrastructure/NewsletterDbRepository.php b/src/Contact/Infrastructure/NewsletterDbRepository.php index ccc40b7..a46f9de 100644 --- a/src/Contact/Infrastructure/NewsletterDbRepository.php +++ b/src/Contact/Infrastructure/NewsletterDbRepository.php @@ -22,6 +22,10 @@ use GetResponse\Contact\DomainModel\NewsletterRepository; +if (!defined('_PS_VERSION_')) { + exit; +} + class NewsletterDbRepository implements NewsletterRepository { public function removeSubscriberFromNewsletter($shopId, $email) diff --git a/src/Ecommerce/Application/Adapter/CartAdapter.php b/src/Ecommerce/Application/Adapter/CartAdapter.php index 95449f2..898541f 100644 --- a/src/Ecommerce/Application/Adapter/CartAdapter.php +++ b/src/Ecommerce/Application/Adapter/CartAdapter.php @@ -23,15 +23,21 @@ use GetResponse\Contact\Application\Adapter\CustomerAdapter; use GetResponse\Ecommerce\DomainModel\Cart; use GetResponse\Ecommerce\DomainModel\Line; +use GetResponse\SharedKernel\CartRecoveryHelper; + +if (!defined('_PS_VERSION_')) { + exit; +} class CartAdapter { /** * @param $cartId + * @param $visitorUuid * * @return Cart */ - public function getCartById($cartId) + public function getCartById($cartId, $visitorUuid) { $prestashopCart = new \Cart($cartId); $customerAdapter = new CustomerAdapter(); @@ -51,6 +57,7 @@ public function getCartById($cartId) } $lines[] = new Line( + $product['id_product'], $variantId, $product['price'], $product['price_wt'], @@ -59,18 +66,17 @@ public function getCartById($cartId) ); } - $shopCartUrl = version_compare(_PS_VERSION_, '1.7', '>=') - ? \Context::getContext()->link->getPageLink('cart', null, null, ['action' => 'show']) - : \Context::getContext()->link->getPageLink('order'); + $cartRecoveryUrl = CartRecoveryHelper::getUrl($prestashopCart->id); return new Cart( $prestashopCart->id, $customer, + $visitorUuid, $lines, $prestashopCart->getOrderTotal(false), $prestashopCart->getOrderTotal(true), $currency->iso_code, - $shopCartUrl, + $cartRecoveryUrl, $prestashopCart->date_add, $prestashopCart->date_upd ); diff --git a/src/Ecommerce/Application/Adapter/ImageAdapter.php b/src/Ecommerce/Application/Adapter/ImageAdapter.php index e4836db..a632ae7 100644 --- a/src/Ecommerce/Application/Adapter/ImageAdapter.php +++ b/src/Ecommerce/Application/Adapter/ImageAdapter.php @@ -23,6 +23,10 @@ use GetResponse\Ecommerce\DomainModel\Image; use Image as PrestashopImage; +if (!defined('_PS_VERSION_')) { + exit; +} + class ImageAdapter { public function getImageById($imageId) diff --git a/src/Ecommerce/Application/Adapter/OrderAdapter.php b/src/Ecommerce/Application/Adapter/OrderAdapter.php index 56920df..684baf4 100644 --- a/src/Ecommerce/Application/Adapter/OrderAdapter.php +++ b/src/Ecommerce/Application/Adapter/OrderAdapter.php @@ -25,6 +25,10 @@ use GetResponse\Ecommerce\DomainModel\Line; use GetResponse\Ecommerce\DomainModel\Order; +if (!defined('_PS_VERSION_')) { + exit; +} + class OrderAdapter { public function getOrderById($orderId) @@ -117,6 +121,7 @@ private function getProducts(\Order $order) } $lines[] = new Line( + $product['product_id'], $variantId, $product['product_price'], $product['product_price_wt'], diff --git a/src/Ecommerce/Application/Adapter/ProductAdapter.php b/src/Ecommerce/Application/Adapter/ProductAdapter.php index b4882ce..c5dd306 100644 --- a/src/Ecommerce/Application/Adapter/ProductAdapter.php +++ b/src/Ecommerce/Application/Adapter/ProductAdapter.php @@ -24,6 +24,10 @@ use GetResponse\Ecommerce\DomainModel\Product; use GetResponse\Ecommerce\DomainModel\Variant; +if (!defined('_PS_VERSION_')) { + exit; +} + class ProductAdapter { const PRODUCT_STATUS_PUBLISH = 'publish'; @@ -67,6 +71,7 @@ public function getProductById($productId, $languageId) foreach ($combinations as $combination) { $variant = new Variant( (int) $combination['id_product_attribute'], + $product->id, $combination['name'], $this->getProductConfigurableSku($combination), $product->getPrice(false, $combination['id_product_attribute']), @@ -87,6 +92,7 @@ public function getProductById($productId, $languageId) } } else { $variants[] = new Variant( + $product->id, $product->id, $product->name[$languageId], $this->getProductSimpleSku($product), diff --git a/src/Ecommerce/Application/CartService.php b/src/Ecommerce/Application/CartService.php index 3d6df88..bad4a63 100644 --- a/src/Ecommerce/Application/CartService.php +++ b/src/Ecommerce/Application/CartService.php @@ -26,6 +26,10 @@ use GetResponse\MessageSender\Application\MessageSenderException; use GetResponse\MessageSender\Application\MessageSenderService; +if (!defined('_PS_VERSION_')) { + exit; +} + class CartService { /** @var MessageSenderService */ @@ -54,8 +58,13 @@ public function upsertCart(UpsertCart $command) return; } + $visitorUuid = null; + if ($configuration->isGetResponseWebTrackingActive() && isset($_COOKIE['gaVisitorUuid'])) { + $visitorUuid = $_COOKIE['gaVisitorUuid']; + } + $cartAdapter = new CartAdapter(); - $cart = $cartAdapter->getCartById($command->getCartId()); + $cart = $cartAdapter->getCartById($command->getCartId(), $visitorUuid); if ($cart->isValuable()) { $this->messageSenderService->send( diff --git a/src/Ecommerce/Application/Command/RecommendedProductCommand.php b/src/Ecommerce/Application/Command/RecommendedProductCommand.php index 0fbc877..7aa5750 100644 --- a/src/Ecommerce/Application/Command/RecommendedProductCommand.php +++ b/src/Ecommerce/Application/Command/RecommendedProductCommand.php @@ -20,6 +20,10 @@ namespace GetResponse\Ecommerce\Application\Command; +if (!defined('_PS_VERSION_')) { + exit; +} + class RecommendedProductCommand { /** @var int */ diff --git a/src/Ecommerce/Application/Command/UpsertCart.php b/src/Ecommerce/Application/Command/UpsertCart.php index d570332..1113f35 100644 --- a/src/Ecommerce/Application/Command/UpsertCart.php +++ b/src/Ecommerce/Application/Command/UpsertCart.php @@ -20,6 +20,10 @@ namespace GetResponse\Ecommerce\Application\Command; +if (!defined('_PS_VERSION_')) { + exit; +} + class UpsertCart { /** @var int */ diff --git a/src/Ecommerce/Application/Command/UpsertOrder.php b/src/Ecommerce/Application/Command/UpsertOrder.php index 0768f1b..dc73af2 100644 --- a/src/Ecommerce/Application/Command/UpsertOrder.php +++ b/src/Ecommerce/Application/Command/UpsertOrder.php @@ -20,6 +20,10 @@ namespace GetResponse\Ecommerce\Application\Command; +if (!defined('_PS_VERSION_')) { + exit; +} + class UpsertOrder { /** @var int */ diff --git a/src/Ecommerce/Application/Command/UpsertProduct.php b/src/Ecommerce/Application/Command/UpsertProduct.php index 3a83c86..e55463a 100644 --- a/src/Ecommerce/Application/Command/UpsertProduct.php +++ b/src/Ecommerce/Application/Command/UpsertProduct.php @@ -20,6 +20,10 @@ namespace GetResponse\Ecommerce\Application\Command; +if (!defined('_PS_VERSION_')) { + exit; +} + class UpsertProduct { /** @var int */ diff --git a/src/Ecommerce/Application/OrderService.php b/src/Ecommerce/Application/OrderService.php index 6e5ccb0..b7e899e 100644 --- a/src/Ecommerce/Application/OrderService.php +++ b/src/Ecommerce/Application/OrderService.php @@ -26,6 +26,10 @@ use GetResponse\MessageSender\Application\MessageSenderException; use GetResponse\MessageSender\Application\MessageSenderService; +if (!defined('_PS_VERSION_')) { + exit; +} + class OrderService { /** @var MessageSenderService */ diff --git a/src/Ecommerce/Application/ProductService.php b/src/Ecommerce/Application/ProductService.php index 0ee5148..166c8a7 100644 --- a/src/Ecommerce/Application/ProductService.php +++ b/src/Ecommerce/Application/ProductService.php @@ -26,6 +26,10 @@ use GetResponse\MessageSender\Application\MessageSenderException; use GetResponse\MessageSender\Application\MessageSenderService; +if (!defined('_PS_VERSION_')) { + exit; +} + class ProductService { /** @var MessageSenderService */ diff --git a/src/Ecommerce/Application/RecommendationService.php b/src/Ecommerce/Application/RecommendationService.php index 18d3295..c64860b 100644 --- a/src/Ecommerce/Application/RecommendationService.php +++ b/src/Ecommerce/Application/RecommendationService.php @@ -24,6 +24,10 @@ use GetResponse\Ecommerce\DomainModel\RecommendedProduct; use GetResponse\Ecommerce\DomainModel\Variant; +if (!defined('_PS_VERSION_')) { + exit; +} + class RecommendationService { private $productAdapter; diff --git a/src/Ecommerce/DomainModel/Address.php b/src/Ecommerce/DomainModel/Address.php index 80674fe..7ae1e0d 100644 --- a/src/Ecommerce/DomainModel/Address.php +++ b/src/Ecommerce/DomainModel/Address.php @@ -20,6 +20,10 @@ namespace GetResponse\Ecommerce\DomainModel; +if (!defined('_PS_VERSION_')) { + exit; +} + class Address implements \JsonSerializable { /** @var string */ diff --git a/src/Ecommerce/DomainModel/Cart.php b/src/Ecommerce/DomainModel/Cart.php index 6414157..7fe1504 100644 --- a/src/Ecommerce/DomainModel/Cart.php +++ b/src/Ecommerce/DomainModel/Cart.php @@ -23,12 +23,18 @@ use GetResponse\Contact\DomainModel\Customer; use GetResponse\SharedKernel\CallbackType; +if (!defined('_PS_VERSION_')) { + exit; +} + class Cart implements \JsonSerializable { /** @var int */ private $id; /** @var Customer */ private $customer; + /** @var ?string */ + private $visitorUuid; /** @var Line[] */ private $lines; /** @var float */ @@ -47,6 +53,7 @@ class Cart implements \JsonSerializable public function __construct( $id, Customer $customer, + $visitorUuid, $lines, $totalPrice, $totalTaxPrice, @@ -57,6 +64,7 @@ public function __construct( ) { $this->id = $id; $this->customer = $customer; + $this->visitorUuid = $visitorUuid; $this->lines = $lines; $this->totalPrice = $totalPrice; $this->totalTaxPrice = $totalTaxPrice; @@ -82,6 +90,14 @@ public function getCustomer() return $this->customer; } + /** + * @return string + */ + public function getVisitorUuid() + { + return $this->visitorUuid; + } + /** * @return Line[] */ @@ -153,6 +169,7 @@ public function jsonSerialize() 'id' => $this->id, 'contact_email' => $this->customer->getEmail(), 'customer' => $this->customer->jsonSerialize(), + 'visitor_uuid' => $this->visitorUuid, 'lines' => $lines, 'total_price' => $this->totalPrice, 'total_price_tax' => $this->totalTaxPrice, @@ -168,6 +185,6 @@ public function jsonSerialize() */ public function isValuable() { - return $this->id !== 0 && $this->customer->getEmail() !== null; + return $this->id !== 0 && ($this->customer->getEmail() !== null || $this->visitorUuid !== null); } } diff --git a/src/Ecommerce/DomainModel/Category.php b/src/Ecommerce/DomainModel/Category.php index 9d2dcf7..546dd8e 100644 --- a/src/Ecommerce/DomainModel/Category.php +++ b/src/Ecommerce/DomainModel/Category.php @@ -20,6 +20,10 @@ namespace GetResponse\Ecommerce\DomainModel; +if (!defined('_PS_VERSION_')) { + exit; +} + class Category implements \JsonSerializable { /** @var int */ diff --git a/src/Ecommerce/DomainModel/Image.php b/src/Ecommerce/DomainModel/Image.php index 4f6c6f1..0385815 100644 --- a/src/Ecommerce/DomainModel/Image.php +++ b/src/Ecommerce/DomainModel/Image.php @@ -20,6 +20,10 @@ namespace GetResponse\Ecommerce\DomainModel; +if (!defined('_PS_VERSION_')) { + exit; +} + class Image implements \JsonSerializable { /** @var string */ diff --git a/src/Ecommerce/DomainModel/Line.php b/src/Ecommerce/DomainModel/Line.php index fc5868a..1287746 100644 --- a/src/Ecommerce/DomainModel/Line.php +++ b/src/Ecommerce/DomainModel/Line.php @@ -20,8 +20,14 @@ namespace GetResponse\Ecommerce\DomainModel; +if (!defined('_PS_VERSION_')) { + exit; +} + class Line implements \JsonSerializable { + /** @var int */ + private $productId; /** @var int */ private $variantId; /** @var float */ @@ -34,12 +40,14 @@ class Line implements \JsonSerializable private $sku; public function __construct( + $productId, $variantId, $price, $priceTax, $quantity, $sku ) { + $this->productId = $productId; $this->variantId = $variantId; $this->price = $price; $this->priceTax = $priceTax; @@ -53,6 +61,7 @@ public function __construct( public function jsonSerialize() { return [ + 'product_id' => $this->productId, 'variant_id' => $this->variantId, 'price' => $this->price, 'price_tax' => $this->priceTax, diff --git a/src/Ecommerce/DomainModel/Order.php b/src/Ecommerce/DomainModel/Order.php index ae36a91..60f79f0 100644 --- a/src/Ecommerce/DomainModel/Order.php +++ b/src/Ecommerce/DomainModel/Order.php @@ -23,6 +23,10 @@ use GetResponse\Contact\DomainModel\Customer; use GetResponse\SharedKernel\CallbackType; +if (!defined('_PS_VERSION_')) { + exit; +} + class Order implements \JsonSerializable { /** @var int */ diff --git a/src/Ecommerce/DomainModel/Product.php b/src/Ecommerce/DomainModel/Product.php index f42258d..f9d0a2f 100644 --- a/src/Ecommerce/DomainModel/Product.php +++ b/src/Ecommerce/DomainModel/Product.php @@ -22,6 +22,10 @@ use GetResponse\SharedKernel\CallbackType; +if (!defined('_PS_VERSION_')) { + exit; +} + class Product implements \JsonSerializable { const CONFIGURABLE_TYPE = 'configurable'; diff --git a/src/Ecommerce/DomainModel/RecommendedProduct.php b/src/Ecommerce/DomainModel/RecommendedProduct.php index 5287fad..97ab6b4 100644 --- a/src/Ecommerce/DomainModel/RecommendedProduct.php +++ b/src/Ecommerce/DomainModel/RecommendedProduct.php @@ -20,6 +20,10 @@ namespace GetResponse\Ecommerce\DomainModel; +if (!defined('_PS_VERSION_')) { + exit; +} + class RecommendedProduct { /** @var string */ diff --git a/src/Ecommerce/DomainModel/Variant.php b/src/Ecommerce/DomainModel/Variant.php index b57c2d8..1fa2750 100644 --- a/src/Ecommerce/DomainModel/Variant.php +++ b/src/Ecommerce/DomainModel/Variant.php @@ -20,10 +20,16 @@ namespace GetResponse\Ecommerce\DomainModel; +if (!defined('_PS_VERSION_')) { + exit; +} + class Variant implements \JsonSerializable { /** @var int */ private $id; + /** @var int */ + private $productId; /** @var string */ private $name; /** @var string */ @@ -55,6 +61,7 @@ class Variant implements \JsonSerializable public function __construct( $id, + $productId, $name, $sku, $price, @@ -71,6 +78,7 @@ public function __construct( $status ) { $this->id = $id; + $this->productId = $productId; $this->name = $name; $this->sku = $sku; $this->price = $price; @@ -95,6 +103,14 @@ public function getId() return $this->id; } + /** + * @return int + */ + public function getProductId() + { + return $this->productId; + } + /** * @return string */ @@ -211,6 +227,7 @@ public function jsonSerialize() return [ 'id' => $this->id, + 'product_id' => $this->productId, 'name' => $this->name, 'sku' => $this->sku, 'price' => $this->price, diff --git a/src/MessageSender/Application/MessageSenderException.php b/src/MessageSender/Application/MessageSenderException.php index 638f44d..2290c36 100644 --- a/src/MessageSender/Application/MessageSenderException.php +++ b/src/MessageSender/Application/MessageSenderException.php @@ -20,6 +20,10 @@ namespace GetResponse\MessageSender\Application; +if (!defined('_PS_VERSION_')) { + exit; +} + class MessageSenderException extends \Exception { public static function createFromPrevious(\Exception $e) diff --git a/src/MessageSender/Application/MessageSenderService.php b/src/MessageSender/Application/MessageSenderService.php index 8a3d61c..3810c8f 100644 --- a/src/MessageSender/Application/MessageSenderService.php +++ b/src/MessageSender/Application/MessageSenderService.php @@ -23,6 +23,10 @@ use GetResponse\MessageSender\DomainModel\EventEmitter; use GetResponse\MessageSender\DomainModel\EventEmitterException; +if (!defined('_PS_VERSION_')) { + exit; +} + class MessageSenderService { /** @var EventEmitter */ diff --git a/src/MessageSender/DomainModel/EventEmitter.php b/src/MessageSender/DomainModel/EventEmitter.php index e471025..28a0683 100644 --- a/src/MessageSender/DomainModel/EventEmitter.php +++ b/src/MessageSender/DomainModel/EventEmitter.php @@ -20,6 +20,10 @@ namespace GetResponse\MessageSender\DomainModel; +if (!defined('_PS_VERSION_')) { + exit; +} + interface EventEmitter { /** diff --git a/src/MessageSender/DomainModel/EventEmitterException.php b/src/MessageSender/DomainModel/EventEmitterException.php index 233b208..7a65cc4 100644 --- a/src/MessageSender/DomainModel/EventEmitterException.php +++ b/src/MessageSender/DomainModel/EventEmitterException.php @@ -20,6 +20,10 @@ namespace GetResponse\MessageSender\DomainModel; +if (!defined('_PS_VERSION_')) { + exit; +} + class EventEmitterException extends \Exception { const INVALID_CURL_RESPONSE = 10001; diff --git a/src/MessageSender/Infrastructure/HttpClient.php b/src/MessageSender/Infrastructure/HttpClient.php index 94f26dd..ac9f538 100644 --- a/src/MessageSender/Infrastructure/HttpClient.php +++ b/src/MessageSender/Infrastructure/HttpClient.php @@ -22,6 +22,11 @@ use GetResponse\MessageSender\DomainModel\EventEmitter; use GetResponse\MessageSender\DomainModel\EventEmitterException; + +if (!defined('_PS_VERSION_')) { + exit; +} + class HttpClient implements EventEmitter { const GET = 'GET'; @@ -100,6 +105,7 @@ public function emit($url, $object) /** * @param \JsonSerializable $object + * * @return string */ private function createHmac($object) diff --git a/src/SharedKernel/CallbackType.php b/src/SharedKernel/CallbackType.php index e003876..418e8e3 100644 --- a/src/SharedKernel/CallbackType.php +++ b/src/SharedKernel/CallbackType.php @@ -20,6 +20,10 @@ namespace GetResponse\SharedKernel; +if (!defined('_PS_VERSION_')) { + exit; +} + class CallbackType { const CHECKOUT_CREATE = 'checkouts/create'; diff --git a/tests/Unit/PrestashopMock/Link.php b/src/SharedKernel/CartRecoveryHelper.php similarity index 63% rename from tests/Unit/PrestashopMock/Link.php rename to src/SharedKernel/CartRecoveryHelper.php index c89613a..54d4ada 100644 --- a/tests/Unit/PrestashopMock/Link.php +++ b/src/SharedKernel/CartRecoveryHelper.php @@ -17,20 +17,27 @@ * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -class Link -{ - public function getProductLink($product) - { - return __PS_BASE_URI__ . 'product/' . $product->id; - } - public function getImageLink($name, $ids, $type = null) +namespace GetResponse\SharedKernel; + +use Context; + +class CartRecoveryHelper +{ + public static function getUrl($cartId) { - return 'my-prestashop.com/product/1/images/default.jpg'; + return Context::getContext()->link->getModuleLink( + 'grprestashop', + 'CartRecovery', + [ + 'cart_id' => $cartId, + 'cart_token' => self::generateCartToken($cartId), + ] + ); } - public function getPageLink($controllerName, $ssl = null, $id_lang = null, $request = null) + public static function generateCartToken($cartId) { - return 'https://my-prestashop.com/pl/koszyk?action=show'; + return md5(_COOKIE_KEY_ . 'recover_cart_' . $cartId); } } diff --git a/tests/Unit/PrestashopMock/Image.php b/src/SharedKernel/Session/CookieStorage.php similarity index 51% rename from tests/Unit/PrestashopMock/Image.php rename to src/SharedKernel/Session/CookieStorage.php index 700dff4..73eaf26 100644 --- a/tests/Unit/PrestashopMock/Image.php +++ b/src/SharedKernel/Session/CookieStorage.php @@ -17,22 +17,44 @@ * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -class Image + +namespace GetResponse\SharedKernel\Session; + +if (!defined('_PS_VERSION_')) { + exit; +} + +class CookieStorage implements Storage { - /** @var int */ - public $id_image; - /** @var int */ - public $position; + private $context; + + /** @var Cookie $storage */ + public function __construct($storage) + { + $this->context = \Context::getContext(); + } - public function __construct($id) + public function exists($keyName) { - $params = ImageParams::getImageById($id); - $this->id_image = $params['id']; - $this->position = $params['position']; + return (bool) $this->context->cookie->__isset($keyName); } - public function getExistingImgPath() + public function set($keyName, $payload) { - return $this->id_image; + $this->context->cookie->__set($keyName, base64_encode($payload)); + } + + public function remove($keyName) + { + $this->context->cookie->__unset($keyName); + } + + public function get($keyName) + { + if (false === $this->exists($keyName)) { + return null; + } + + return base64_decode($this->context->cookie->__get($keyName)); } } diff --git a/tests/Unit/PrestashopMock/Tools.php b/src/SharedKernel/Session/SessionStorage.php similarity index 52% rename from tests/Unit/PrestashopMock/Tools.php rename to src/SharedKernel/Session/SessionStorage.php index 00d0b11..acab6cd 100644 --- a/tests/Unit/PrestashopMock/Tools.php +++ b/src/SharedKernel/Session/SessionStorage.php @@ -17,19 +17,45 @@ * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -class Tools + +namespace GetResponse\SharedKernel\Session; + +use Symfony\Component\HttpFoundation\Session\SessionInterface; + +if (!defined('_PS_VERSION_')) { + exit; +} + +class SessionStorage implements Storage { - public static function getProtocol($use_ssl = null) + private $session; + + public function __construct(SessionInterface $session) { - return 'https://'; + $this->session = $session; } - public static function usingSecureMode() + public function exists($keyName) { + return $this->session->has($keyName); } - public static function getHttpHost($http) + public function set($keyName, $payload) { - return ''; + $this->session->set($keyName, base64_encode($payload)); + } + + public function remove($keyName) + { + $this->session->remove($keyName); + } + + public function get($keyName) + { + if (!$this->exists($keyName)) { + return null; + } + + return base64_decode($this->session->get($keyName)); } } diff --git a/tests/Unit/PrestashopMock/Context.php b/src/SharedKernel/Session/Storage.php similarity index 75% rename from tests/Unit/PrestashopMock/Context.php rename to src/SharedKernel/Session/Storage.php index 9f6712c..b19a4bd 100644 --- a/tests/Unit/PrestashopMock/Context.php +++ b/src/SharedKernel/Session/Storage.php @@ -17,20 +17,20 @@ * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -class Context + +namespace GetResponse\SharedKernel\Session; + +if (!defined('_PS_VERSION_')) { + exit; +} + +interface Storage { - /** @var Link */ - public $link; + public function exists($keyName); + + public function set($keyName, $payload); - public function __construct($link) - { - $this->link = $link; - } + public function remove($keyName); - public static function getContext() - { - return new self( - new Link() - ); - } + public function get($keyName); } diff --git a/tests/Unit/BaseTestCase.php b/src/SharedKernel/Session/StorageFactory.php similarity index 50% rename from tests/Unit/BaseTestCase.php rename to src/SharedKernel/Session/StorageFactory.php index 4134572..f11f46d 100644 --- a/tests/Unit/BaseTestCase.php +++ b/src/SharedKernel/Session/StorageFactory.php @@ -18,26 +18,38 @@ * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -namespace GetResponse\Tests\Unit; +namespace GetResponse\SharedKernel\Session; -use PHPUnit\Framework\TestCase; +use RuntimeException; +use Symfony\Component\HttpFoundation\Session\SessionInterface; -/** - * Class BaseTestCase - */ -class BaseTestCase extends TestCase +class StorageFactory { + public function create() + { + try { + $context = \Context::getContext(); + + /** @var SessionInterface|null $session */ + $session = $context->session; + + if ($session instanceof SessionInterface) { + return new SessionStorage($session); + } + + if ($context->cookie) { + return new CookieStorage($context->cookie); + } + } catch (RuntimeException $e) { + $this->logGetResponseError($e->getMessage()); + } + } + /** - * @param string $name - * @param string[] $methodsToOverride - * - * @return \PHPUnit_Framework_MockObject_MockObject|object + * @param string $message */ - protected function getMockWithoutConstructing($name, array $methodsToOverride = []) + private function logGetResponseError($message) { - return $this->getMockBuilder($name) - ->disableOriginalConstructor() - ->setMethods($methodsToOverride) - ->getMock(); + PrestaShopLoggerCore::addLog($message, 2, null, 'GetResponse', 'GetResponse'); } } diff --git a/tests/Unit/Contact/Application/index.php b/src/SharedKernel/Session/index.php similarity index 74% rename from tests/Unit/Contact/Application/index.php rename to src/SharedKernel/Session/index.php index 296d682..74851d7 100644 --- a/tests/Unit/Contact/Application/index.php +++ b/src/SharedKernel/Session/index.php @@ -17,12 +17,14 @@ * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); -header('Location: ../'); +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); exit; diff --git a/src/SharedKernel/SessionStorage.php b/src/SharedKernel/SessionStorage.php index 5e78d85..421a279 100644 --- a/src/SharedKernel/SessionStorage.php +++ b/src/SharedKernel/SessionStorage.php @@ -20,14 +20,17 @@ namespace GetResponse\SharedKernel; -use Context; +if (!defined('_PS_VERSION_')) { + exit; +} class SessionStorage { private $context; + public function __construct() { - $this->context = Context::getContext(); + $this->context = \Context::getContext(); } public function exists($keyName) diff --git a/src/TrackingCode/Application/Adapter/CartAdapter.php b/src/TrackingCode/Application/Adapter/CartAdapter.php index b0d5315..0e0587d 100644 --- a/src/TrackingCode/Application/Adapter/CartAdapter.php +++ b/src/TrackingCode/Application/Adapter/CartAdapter.php @@ -20,21 +20,25 @@ namespace GetResponse\TrackingCode\Application\Adapter; +use GetResponse\SharedKernel\CartRecoveryHelper; use GetResponse\TrackingCode\DomainModel\Cart; use GetResponse\TrackingCode\DomainModel\Product; +if (!defined('_PS_VERSION_')) { + exit; +} + class CartAdapter { public function getCartById($cartId) { $prestashopCart = new \Cart($cartId); $currency = new \Currency($prestashopCart->id_currency); - $shopCartUrl = \Context::getContext()->link->getPageLink('cart', null, null, ['action' => 'show']); + $cartRecoveryUrl = CartRecoveryHelper::getUrl($prestashopCart->id); $products = []; foreach ($prestashopCart->getProducts(true) as $product) { - $products[] = new Product( $product['id_product'], $product['price_wt'], @@ -47,7 +51,7 @@ public function getCartById($cartId) $prestashopCart->id, $prestashopCart->getOrderTotal(true), $currency->iso_code, - $shopCartUrl, + $cartRecoveryUrl, $products ); } diff --git a/src/TrackingCode/Application/Adapter/OrderAdapter.php b/src/TrackingCode/Application/Adapter/OrderAdapter.php index 0f9c212..7693649 100644 --- a/src/TrackingCode/Application/Adapter/OrderAdapter.php +++ b/src/TrackingCode/Application/Adapter/OrderAdapter.php @@ -23,6 +23,10 @@ use GetResponse\TrackingCode\DomainModel\Order; use GetResponse\TrackingCode\DomainModel\Product; +if (!defined('_PS_VERSION_')) { + exit; +} + class OrderAdapter { public function getOrderById($orderId) @@ -33,7 +37,6 @@ public function getOrderById($orderId) $products = []; foreach ($order->getProducts() as $product) { - $products[] = new Product( $product['id_product'], $product['product_price_wt'], diff --git a/src/TrackingCode/Application/CartService.php b/src/TrackingCode/Application/CartService.php index 37636cc..787c72f 100644 --- a/src/TrackingCode/Application/CartService.php +++ b/src/TrackingCode/Application/CartService.php @@ -22,10 +22,13 @@ use GetResponse\Configuration\ReadModel\ConfigurationReadModel; use GetResponse\TrackingCode\Application\Adapter\CartAdapter; -use GetResponse\TrackingCode\Application\Command\AddCartToBuffer; use GetResponse\TrackingCode\DomainModel\Cart; use GetResponse\TrackingCode\DomainModel\TrackingCodeBufferService; +if (!defined('_PS_VERSION_')) { + exit; +} + class CartService { /** @var ConfigurationReadModel */ @@ -61,6 +64,7 @@ public function addCartToBuffer($cartId, $shopId) /** * @param int $shopId + * * @return Cart|null */ public function getCartFromBuffer($shopId) diff --git a/src/TrackingCode/Application/OrderService.php b/src/TrackingCode/Application/OrderService.php index 0790221..7d5c173 100644 --- a/src/TrackingCode/Application/OrderService.php +++ b/src/TrackingCode/Application/OrderService.php @@ -21,12 +21,14 @@ namespace GetResponse\TrackingCode\Application; use GetResponse\Configuration\ReadModel\ConfigurationReadModel; -use GetResponse\TrackingCode\Application\Adapter\CartAdapter; use GetResponse\TrackingCode\Application\Adapter\OrderAdapter; -use GetResponse\TrackingCode\Application\Command\AddCartToBuffer; use GetResponse\TrackingCode\DomainModel\Order; use GetResponse\TrackingCode\DomainModel\TrackingCodeBufferService; +if (!defined('_PS_VERSION_')) { + exit; +} + class OrderService { /** @var ConfigurationReadModel */ @@ -62,6 +64,7 @@ public function addOrderToBuffer($orderId, $shopId) /** * @param int $shopId + * * @return Order|null */ public function getOrderFromBuffer($shopId) diff --git a/src/TrackingCode/DomainModel/Cart.php b/src/TrackingCode/DomainModel/Cart.php index 422f72b..5925aa5 100644 --- a/src/TrackingCode/DomainModel/Cart.php +++ b/src/TrackingCode/DomainModel/Cart.php @@ -20,6 +20,10 @@ namespace GetResponse\TrackingCode\DomainModel; +if (!defined('_PS_VERSION_')) { + exit; +} + class Cart { /** @var int */ @@ -44,6 +48,7 @@ public function __construct($id, $price, $currency, $url, $products) /** * @param array $cart + * * @return self */ public static function createFromArray($cart) @@ -73,7 +78,7 @@ public function toArray() 'price' => $this->price, 'currency' => $this->currency, 'url' => $this->url, - 'products' => $products + 'products' => $products, ]; } diff --git a/src/TrackingCode/DomainModel/Order.php b/src/TrackingCode/DomainModel/Order.php index 1c9ca67..e7696a2 100644 --- a/src/TrackingCode/DomainModel/Order.php +++ b/src/TrackingCode/DomainModel/Order.php @@ -20,6 +20,10 @@ namespace GetResponse\TrackingCode\DomainModel; +if (!defined('_PS_VERSION_')) { + exit; +} + class Order { /** @var int */ @@ -98,12 +102,13 @@ public function toArray() 'cartId' => (string) $this->cartId, 'price' => (float) $this->price, 'currency' => $this->currency, - 'products' => $products + 'products' => $products, ]; } /** * @param array $order + * * @return self */ public static function createFromArray($order) diff --git a/src/TrackingCode/DomainModel/Product.php b/src/TrackingCode/DomainModel/Product.php index f8d6719..c4bbfde 100644 --- a/src/TrackingCode/DomainModel/Product.php +++ b/src/TrackingCode/DomainModel/Product.php @@ -20,6 +20,10 @@ namespace GetResponse\TrackingCode\DomainModel; +if (!defined('_PS_VERSION_')) { + exit; +} + class Product { /** @var int */ @@ -80,17 +84,17 @@ public function toArray() 'id' => (string) $this->id, 'price' => $this->price, 'currency' => $this->currency, - 'quantity' => (int) $this->quantity + 'quantity' => (int) $this->quantity, ]; } /** * @param array $product + * * @return self */ public static function createFromArray($product) { return new self($product['id'], $product['price'], $product['currency'], $product['quantity']); } - } diff --git a/src/TrackingCode/DomainModel/TrackingCodeBufferService.php b/src/TrackingCode/DomainModel/TrackingCodeBufferService.php index 981b962..d42ea5a 100644 --- a/src/TrackingCode/DomainModel/TrackingCodeBufferService.php +++ b/src/TrackingCode/DomainModel/TrackingCodeBufferService.php @@ -20,7 +20,11 @@ namespace GetResponse\TrackingCode\DomainModel; -use GetResponse\SharedKernel\SessionStorage; +use GetResponse\SharedKernel\Session\Storage; + +if (!defined('_PS_VERSION_')) { + exit; +} class TrackingCodeBufferService { @@ -28,7 +32,7 @@ class TrackingCodeBufferService const CART_COOKIE_NAME = 'gr4prestashop_cart'; const ORDER_COOKIE_NAME = 'gr4prestashop_order'; - /** @var SessionStorage */ + /** @var Storage */ private $sessionStorage; public function __construct($sessionStorage) @@ -66,6 +70,7 @@ public function getCartFromBuffer() } $this->sessionStorage->remove(self::CART_COOKIE_NAME); + return Cart::createFromArray(unserialize($cart)); } @@ -90,6 +95,7 @@ public function getOrderFromBuffer() } $this->sessionStorage->remove(self::ORDER_COOKIE_NAME); + return Order::createFromArray(unserialize($order)); } } diff --git a/src/TrackingCode/Presenter/CartPresenter.php b/src/TrackingCode/Presenter/CartPresenter.php index 6100b77..3c1f0b1 100644 --- a/src/TrackingCode/Presenter/CartPresenter.php +++ b/src/TrackingCode/Presenter/CartPresenter.php @@ -22,10 +22,15 @@ use GetResponse\TrackingCode\DomainModel\Cart; +if (!defined('_PS_VERSION_')) { + exit; +} + class CartPresenter extends EcommercePresenter { /** @var Cart */ private $cart; + /** * @param Cart $cart */ @@ -42,11 +47,10 @@ public function present() $products = []; foreach ($this->cart->getProducts() as $product) { - $products[] = [ 'product' => $this->getProduct($product), 'quantity' => $product->getQuantity(), - 'categories' => $this->getProductCategories($product->getId()) + 'categories' => $this->getProductCategories($product->getId()), ]; } @@ -55,7 +59,7 @@ public function present() 'cartId' => (string) $this->cart->getId(), 'currency' => $this->cart->getCurrency(), 'cartUrl' => $this->cart->getUrl(), - 'products' => $products + 'products' => $products, ]; } } diff --git a/src/TrackingCode/Presenter/EcommercePresenter.php b/src/TrackingCode/Presenter/EcommercePresenter.php index 0ba37a0..39ff124 100644 --- a/src/TrackingCode/Presenter/EcommercePresenter.php +++ b/src/TrackingCode/Presenter/EcommercePresenter.php @@ -1,15 +1,36 @@ + * @copyright Since 2007 PrestaShop SA and Contributors + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 + */ namespace GetResponse\TrackingCode\Presenter; use GetResponse\TrackingCode\DomainModel\Product; +if (!defined('_PS_VERSION_')) { + exit; +} + class EcommercePresenter { /** * @param int $productId + * * @return array */ protected function getProductCategories($productId) @@ -29,9 +50,10 @@ protected function getProductCategories($productId) /** * @param Product $product + * * @return array */ - protected function getProduct( $product) + protected function getProduct($product) { $prestashopProduct = new \Product($product->getId()); @@ -42,7 +64,7 @@ protected function getProduct( $product) 'name' => $productName, 'price' => number_format($product->getPrice(), 2), 'sku' => $prestashopProduct->reference, - 'currency' => $product->getCurrency() + 'currency' => $product->getCurrency(), ]; } } diff --git a/src/TrackingCode/Presenter/OrderPresenter.php b/src/TrackingCode/Presenter/OrderPresenter.php index cd54910..ecf5375 100644 --- a/src/TrackingCode/Presenter/OrderPresenter.php +++ b/src/TrackingCode/Presenter/OrderPresenter.php @@ -22,6 +22,10 @@ use GetResponse\TrackingCode\DomainModel\Order; +if (!defined('_PS_VERSION_')) { + exit; +} + class OrderPresenter extends EcommercePresenter { /** @var Order */ @@ -43,11 +47,10 @@ public function present() $products = []; foreach ($this->order->getProducts() as $product) { - $products[] = [ 'product' => $this->getProduct($product), 'quantity' => (int) $product->getQuantity(), - 'categories' => $this->getProductCategories($product->getId()) + 'categories' => $this->getProductCategories($product->getId()), ]; } @@ -56,7 +59,7 @@ public function present() 'cartId' => (string) $this->order->getCartId(), 'orderId' => (string) $this->order->getId(), 'currency' => $this->order->getCurrency(), - 'products' => $products + 'products' => $products, ]; } } diff --git a/tests/Unit/Configuration/Application/index.php b/src/TrackingCode/Presenter/index.php similarity index 100% rename from tests/Unit/Configuration/Application/index.php rename to src/TrackingCode/Presenter/index.php diff --git a/tests/Unit/Configuration/Application/ConfigurationServiceTest.php b/tests/Unit/Configuration/Application/ConfigurationServiceTest.php deleted file mode 100644 index 57840ca..0000000 --- a/tests/Unit/Configuration/Application/ConfigurationServiceTest.php +++ /dev/null @@ -1,83 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace GetResponse\Tests\Unit\Configuration\Application; - -use GetResponse\Configuration\Application\Command\UpsertConfiguration; -use GetResponse\Configuration\Application\ConfigurationService; -use GetResponse\Configuration\Domain\Configuration; -use GetResponse\Configuration\Domain\ConfigurationRepository; -use GetResponse\Tests\Unit\BaseTestCase; - -class ConfigurationServiceTest extends BaseTestCase -{ - /** @var ConfigurationService */ - private $sut; - - /** @var ConfigurationRepository|\PHPUnit_Framework_MockObject_MockObject */ - private $configurationRepositoryMock; - - protected function setUp() - { - $this->configurationRepositoryMock = $this->getMockWithoutConstructing(ConfigurationRepository::class); - $this->sut = new ConfigurationService($this->configurationRepositoryMock); - } - - /** - * @test - */ - public function shouldCreateConfiguration() - { - $command = new UpsertConfiguration( - 1, - 'facebookPixelSnippet', - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null - ); - - $this->configurationRepositoryMock - ->expects(self::once()) - ->method('upsertConfiguration') - ->with( - new Configuration( - 1, 'facebookPixelSnippet', - null, - null, - null, - null, - null, - null, - null, - null - ) - ); - - $this->sut->upsertConfiguration($command); - } -} diff --git a/tests/Unit/Contact/Application/Adapter/CustomerAdapterTest.php b/tests/Unit/Contact/Application/Adapter/CustomerAdapterTest.php deleted file mode 100644 index 36e0e35..0000000 --- a/tests/Unit/Contact/Application/Adapter/CustomerAdapterTest.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace GetResponse\Tests\Unit\Contact\Application\Adapter; - -use GetResponse\Contact\Application\Adapter\CustomerAdapter; -use GetResponse\Tests\Unit\BaseTestCase; - -class CustomerAdapterTest extends BaseTestCase -{ - /** - * @test - */ - public function shouldCreateCommandWithSubscribedToNewsletter() - { - $prestashopCustomer = new \Customer(1); - - $adapter = new CustomerAdapter(); - $customer = $adapter->getCustomerById(1); - - self::assertEquals($prestashopCustomer->firstname, $customer->getFirstName()); - self::assertEquals($prestashopCustomer->lastname, $customer->getLastName()); - self::assertEquals($prestashopCustomer->email, $customer->getEmail()); - self::assertTrue($customer->getMarketingConsent()); - } - - /** - * @test - */ - public function shouldCreateCommandWithNotSubscribedToNewsletter() - { - $prestashopCustomer = new \Customer(2); - - $adapter = new CustomerAdapter(); - $customer = $adapter->getCustomerById(2); - - self::assertEquals($prestashopCustomer->firstname, $customer->getFirstName()); - self::assertEquals($prestashopCustomer->lastname, $customer->getLastName()); - self::assertEquals($prestashopCustomer->email, $customer->getEmail()); - self::assertFalse($customer->getMarketingConsent()); - } -} diff --git a/tests/Unit/Contact/Application/ContactServiceTest.php b/tests/Unit/Contact/Application/ContactServiceTest.php deleted file mode 100644 index fff4d94..0000000 --- a/tests/Unit/Contact/Application/ContactServiceTest.php +++ /dev/null @@ -1,126 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace GetResponse\Tests\Unit\Contact\Application; - -use GetResponse\Configuration\ReadModel\ConfigurationDto; -use GetResponse\Configuration\ReadModel\ConfigurationReadModel; -use GetResponse\Contact\Application\Command\UpsertCustomer; -use GetResponse\Contact\Application\ContactService; -use GetResponse\Contact\DomainModel\Customer; -use GetResponse\Ecommerce\DomainModel\Address; -use GetResponse\MessageSender\Application\MessageSenderService; -use GetResponse\Tests\Unit\BaseTestCase; - -class ContactServiceTest extends BaseTestCase -{ - /** @var MessageSenderService|\PHPUnit_Framework_MockObject_MockObject */ - private $messageSenderServiceMock; - /** @var ConfigurationReadModel|\PHPUnit_Framework_MockObject_MockObject */ - private $configurationReadModelMock; - - /** @var ContactService */ - private $sut; - - public function setUp() - { - $this->messageSenderServiceMock = $this->getMockWithoutConstructing(MessageSenderService::class); - $this->configurationReadModelMock = $this->getMockWithoutConstructing(ConfigurationReadModel::class); - - $this->sut = new ContactService($this->messageSenderServiceMock, $this->configurationReadModelMock); - } - - /** - * @test - */ - public function shouldSendContactToGetResponse() - { - $liveSynchronizationUrl = 'https://app.getreponse.com/callback/ecommerce/33983'; - - $configurationDTOMock = $this->getMockWithoutConstructing(ConfigurationDto::class); - $configurationDTOMock - ->expects(self::once()) - ->method('isContactLiveSynchronizationActive') - ->willReturn(true); - - $configurationDTOMock - ->expects(self::once()) - ->method('getLiveSynchronizationUrl') - ->willReturn($liveSynchronizationUrl); - - $address = new Address( - 'home', - 'Poland', - 'John', - 'Doe', - 'Street 1', - '', - 'City', - 'PostCode', - 'State', - '', - '544 404 400', - '' - ); - - $customerMock = new Customer(1, 'John', 'Doe', 'john.doe@example.com', $address, true, ['birthday' => '1987-09-04']); - - $command = new UpsertCustomer(1, 1); - - $this->configurationReadModelMock - ->expects(self::once()) - ->method('getConfigurationForShop') - ->with(1) - ->willReturn($configurationDTOMock); - - $this->messageSenderServiceMock - ->expects(self::once()) - ->method('send') - ->with($liveSynchronizationUrl, $customerMock); - - $this->sut->upsertCustomer($command); - } - - /** - * @test - */ - public function shouldSkipWhenLiveSyncIsDisabled() - { - $configurationDTOMock = $this->getMockWithoutConstructing(ConfigurationDto::class); - $configurationDTOMock - ->expects(self::once()) - ->method('isContactLiveSynchronizationActive') - ->willReturn(false); - - $command = new UpsertCustomer(1, 1, 'John', 'Doe', 'john.doe@example.com', true); - - $this->configurationReadModelMock - ->expects(self::once()) - ->method('getConfigurationForShop') - ->with(1) - ->willReturn($configurationDTOMock); - - $this->messageSenderServiceMock - ->expects(self::never()) - ->method('send'); - - $this->sut->upsertCustomer($command); - } -} diff --git a/tests/Unit/Contact/Application/SubscriberServiceTest.php b/tests/Unit/Contact/Application/SubscriberServiceTest.php deleted file mode 100644 index 04c3d11..0000000 --- a/tests/Unit/Contact/Application/SubscriberServiceTest.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace GetResponse\Tests\Unit\Contact\Application; - -use GetResponse\Contact\Application\Command\UnsubscribeContact; -use GetResponse\Contact\Application\SubscriberService; -use GetResponse\Contact\DomainModel\NewsletterRepository; -use GetResponse\Tests\Unit\BaseTestCase; - -class SubscriberServiceTest extends BaseTestCase -{ - /** @var NewsletterRepository|\PHPUnit_Framework_MockObject_MockObject */ - private $newsletterRepositoryMock; - - /** @var SubscriberService */ - private $sut; - - public function setUp() - { - $this->newsletterRepositoryMock = $this->getMockWithoutConstructing(NewsletterRepository::class); - - $this->sut = new SubscriberService($this->newsletterRepositoryMock); - } - - /** - * @test - */ - public function shouldUnsubscribeContact() - { - $shopId = 3; - $email = 'some@email.com'; - - $this->newsletterRepositoryMock - ->expects(self::once()) - ->method('removeSubscriberFromNewsletter') - ->with($shopId, $email); - - $this->newsletterRepositoryMock - ->expects(self::once()) - ->method('removeCustomerFromNewsletter') - ->with($shopId, $email); - - $this->sut->unsubscribe( - new UnsubscribeContact($shopId, $email) - ); - } -} diff --git a/tests/Unit/Contact/index.php b/tests/Unit/Contact/index.php deleted file mode 100644 index 296d682..0000000 --- a/tests/Unit/Contact/index.php +++ /dev/null @@ -1,28 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -exit; diff --git a/tests/Unit/Ecommerce/Application/Adapter/OrderAdapterTest.php b/tests/Unit/Ecommerce/Application/Adapter/OrderAdapterTest.php deleted file mode 100644 index e55db5d..0000000 --- a/tests/Unit/Ecommerce/Application/Adapter/OrderAdapterTest.php +++ /dev/null @@ -1,73 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace GetResponse\Tests\Unit\Ecommerce\Application\Adapter; - -use GetResponse\Contact\DomainModel\Customer; -use GetResponse\Ecommerce\Application\Adapter\OrderAdapter; -use GetResponse\Ecommerce\DomainModel\Address; -use GetResponse\Ecommerce\DomainModel\Order; -use GetResponse\Tests\Unit\BaseTestCase; - -class OrderAdapterTest extends BaseTestCase -{ - /** - * @test - */ - public function shouldCreateOrderFromCommand() - { - $order = new \Order(1); - - $orderUrl = 'https://my-prestashop.com/?controller=order-detail&id_order=' . $order->id; - - $productLines = []; - $currency = new \Currency($order->id_currency); - $orderStatus = new \OrderState($order->getCurrentState(), $order->id_lang); - - $customerAddress = new Address('home', 'Poland', 'John', 'Doe', 'Street 1', '', 'City', 'PostCode', 'State', '', '544 404 400', ''); - $customer = new Customer(1, 'John', 'Doe', 'john.doe@example.com', $customerAddress, 1, ['birthday' => '1987-09-04']); - - $address = new Address('home', 'pl', 'John', 'Doe', 'address1', 'address2', 'city', 'postcode', 'state', '', '544404400', 'company'); - - $expectedOrder = new Order( - $order->id, - $order->reference, - $order->id_cart, - 'john.doe@example.com', - $customer, - $productLines, - $orderUrl, - $order->total_paid_tax_excl, - $order->total_paid_tax_incl, - $order->total_shipping_tax_incl, - $currency->iso_code, - $orderStatus->name, - $address, - $address, - $order->date_add, - $order->date_upd - ); - - $orderAdapter = new OrderAdapter(); - $orderFromCommand = $orderAdapter->getOrderById($order->id); - - self::assertEquals($expectedOrder, $orderFromCommand); - } -} diff --git a/tests/Unit/Ecommerce/Application/Adapter/ProductAdapterTest.php b/tests/Unit/Ecommerce/Application/Adapter/ProductAdapterTest.php deleted file mode 100644 index 2fdacd2..0000000 --- a/tests/Unit/Ecommerce/Application/Adapter/ProductAdapterTest.php +++ /dev/null @@ -1,137 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace GetResponse\Tests\Unit\Ecommerce\Application\Adapter; - -use GetResponse\Ecommerce\Application\Adapter\ProductAdapter; -use GetResponse\Ecommerce\DomainModel\Category; -use GetResponse\Ecommerce\DomainModel\Image; -use GetResponse\Ecommerce\DomainModel\Product; -use GetResponse\Ecommerce\DomainModel\Variant; -use GetResponse\Tests\Unit\BaseTestCase; - -class ProductAdapterTest extends BaseTestCase -{ - /** @var ProductAdapter */ - private $sut; - - public function setUp() - { - $this->sut = new ProductAdapter(); - } - - /** - * @test - */ - public function shouldCreateSimpleProduct() - { - $productId = 1; - $languageId = 1; - - $product = $this->sut->getProductById($productId, $languageId); - - $categories = [ - new Category(3, 1, 'Default category'), - ]; - - $images = [ - new Image('https://my-prestashop.com/img/p/2.jpg', 2), - ]; - - $variants = [ - new Variant( - 1, - 'Test Product', - 'test_product_1', - 19.99, - 19.99, - 29.99, - 29.99, - 100, - 'https://my-prestashop.com/product/1', - null, - null, - 'description short', - 'description', - $images, - 'publish' - ), - ]; - - self::assertEquals($productId, $product->getId()); - self::assertEquals('Test Product', $product->getName()); - self::assertEquals(Product::SINGLE_TYPE, $product->getType()); - self::assertEquals('https://my-prestashop.com/product/1', $product->getUrl()); - self::assertEquals('VendorName', $product->getVendor()); - self::assertEquals($categories, $product->getCategories()); - self::assertEquals($variants, $product->getVariants()); - self::assertEquals('2020-01-05 12:45:22', $product->getCreatedAt()); - self::assertEquals('2020-01-06 12:34:12', $product->getUpdatedAt()); - } - - /** - * @test - */ - public function shouldCreateConfigurableProduct() - { - $productId = 2; - $languageId = 1; - - $product = $this->sut->getProductById($productId, $languageId); - - $categories = [ - new Category(3, 1, 'Default category'), - ]; - - $images = [ - new Image('https://my-prestashop.com/img/p/2.jpg', 2), - ]; - - $variants = [ - new Variant( - 12, - 'Size - Size L', - 'test_product_1', - 19.99, - 19.99, - 29.99, - 29.99, - 100, - 'https://my-prestashop.com/product/2', - null, - null, - 'description short', - 'description', - $images, - 'publish' - ), - ]; - - self::assertEquals($productId, $product->getId()); - self::assertEquals('Test Product', $product->getName()); - self::assertEquals(Product::CONFIGURABLE_TYPE, $product->getType()); - self::assertEquals('https://my-prestashop.com/product/2', $product->getUrl()); - self::assertEquals('VendorName', $product->getVendor()); - self::assertEquals($categories, $product->getCategories()); - self::assertEquals($variants, $product->getVariants()); - self::assertEquals('2020-01-05 12:45:22', $product->getCreatedAt()); - self::assertEquals('2020-01-06 12:34:12', $product->getUpdatedAt()); - } -} diff --git a/tests/Unit/Ecommerce/Application/Adapter/index.php b/tests/Unit/Ecommerce/Application/Adapter/index.php deleted file mode 100644 index 296d682..0000000 --- a/tests/Unit/Ecommerce/Application/Adapter/index.php +++ /dev/null @@ -1,28 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -exit; diff --git a/tests/Unit/Ecommerce/Application/CartServiceTest.php b/tests/Unit/Ecommerce/Application/CartServiceTest.php deleted file mode 100644 index bbb69c5..0000000 --- a/tests/Unit/Ecommerce/Application/CartServiceTest.php +++ /dev/null @@ -1,117 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace GetResponse\Tests\Unit\Ecommerce\Application; - -use GetResponse\Configuration\ReadModel\ConfigurationDto; -use GetResponse\Configuration\ReadModel\ConfigurationReadModel; -use GetResponse\Contact\DomainModel\Customer; -use GetResponse\Ecommerce\Application\CartService; -use GetResponse\Ecommerce\Application\Command\UpsertCart; -use GetResponse\Ecommerce\DomainModel\Address; -use GetResponse\Ecommerce\DomainModel\Cart; -use GetResponse\Ecommerce\DomainModel\Line; -use GetResponse\MessageSender\Application\MessageSenderService; -use GetResponse\Tests\Unit\BaseTestCase; - -class CartServiceTest extends BaseTestCase -{ - /** @var MessageSenderService|\PHPUnit_Framework_MockObject_MockObject */ - private $messageSenderServiceMock; - /** @var ConfigurationReadModel|\PHPUnit_Framework_MockObject_MockObject */ - private $configurationReadModelMock; - /** @var CartService */ - private $sut; - - public function setUp() - { - $this->messageSenderServiceMock = $this->getMockWithoutConstructing(MessageSenderService::class); - $this->configurationReadModelMock = $this->getMockWithoutConstructing(ConfigurationReadModel::class); - - $this->sut = new CartService($this->messageSenderServiceMock, $this->configurationReadModelMock); - } - - /** - * @test - */ - public function shouldUpsertCart() - { - $shopId = 3; - $liveSynchronizationUrl = 'https://app.getreponse.com/callback/ecommerce/33983'; - - $configurationDTOMock = $this->getMockWithoutConstructing(ConfigurationDto::class); - - $configurationDTOMock - ->expects(self::once()) - ->method('isEcommerceLiveSynchronizationActive') - ->willReturn(true); - - $configurationDTOMock - ->expects(self::once()) - ->method('getLiveSynchronizationUrl') - ->willReturn($liveSynchronizationUrl); - - $this->configurationReadModelMock - ->expects(self::once()) - ->method('getConfigurationForShop') - ->with($shopId) - ->willReturn($configurationDTOMock); - - $address = new Address( - 'home', - 'Poland', - 'John', - 'Doe', - 'Street 1', - '', - 'City', - 'PostCode', - 'State', - '', - '544 404 400', - '' - ); - - $customerMock = new Customer(1, 'John', 'Doe', 'john.doe@example.com', $address, true, ['birthday' => '1987-09-04']); - - $line = new Line(1, 29.99, 34.43, 1, 'product_combination_1'); - - $cartMock = new Cart( - 1, - $customerMock, - [$line], - 29.99, - 34.43, - 'eur', - 'https://my-prestashop.com/pl/koszyk?action=show', - '2020-05-12 11:43:59', - '2020-05-14 16:32:03' - ); - - $this->messageSenderServiceMock - ->expects(self::once()) - ->method('send') - ->with($liveSynchronizationUrl, $cartMock); - - $command = new UpsertCart(1, $shopId); - - $this->sut->upsertCart($command); - } -} diff --git a/tests/Unit/Ecommerce/Application/OrderServiceTest.php b/tests/Unit/Ecommerce/Application/OrderServiceTest.php deleted file mode 100644 index 20f7f8c..0000000 --- a/tests/Unit/Ecommerce/Application/OrderServiceTest.php +++ /dev/null @@ -1,114 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace GetResponse\Tests\Unit\Ecommerce\Application; - -use GetResponse\Configuration\ReadModel\ConfigurationDto; -use GetResponse\Configuration\ReadModel\ConfigurationReadModel; -use GetResponse\Ecommerce\Application\Command\UpsertOrder; -use GetResponse\Ecommerce\Application\OrderService; -use GetResponse\MessageSender\Application\MessageSenderService; -use GetResponse\Tests\Unit\BaseTestCase; - -class OrderServiceTest extends BaseTestCase -{ - /** @var MessageSenderService|\PHPUnit_Framework_MockObject_MockObject */ - private $messageSenderServiceMock; - /** @var ConfigurationReadModel|\PHPUnit_Framework_MockObject_MockObject */ - private $configurationReadModelMock; - /** @var OrderService() */ - private $sut; - - public function setUp() - { - $this->messageSenderServiceMock = $this->getMockWithoutConstructing(MessageSenderService::class); - $this->configurationReadModelMock = $this->getMockWithoutConstructing(ConfigurationReadModel::class); - - $this->sut = new OrderService($this->messageSenderServiceMock, $this->configurationReadModelMock); - } - - /** - * @test - */ - public function shouldUpsertOrder() - { - $shopId = 1; - $orderId = 1; - $liveSynchronizationUrl = 'https://app.getreponse.com/callback/ecommerce/33983'; - - $configurationDTOMock = $this->getMockWithoutConstructing(ConfigurationDto::class); - - $configurationDTOMock - ->expects(self::once()) - ->method('isEcommerceLiveSynchronizationActive') - ->willReturn(true); - - $configurationDTOMock - ->expects(self::once()) - ->method('getLiveSynchronizationUrl') - ->willReturn($liveSynchronizationUrl); - - $this->configurationReadModelMock - ->expects(self::once()) - ->method('getConfigurationForShop') - ->with($shopId) - ->willReturn($configurationDTOMock); - - $this->messageSenderServiceMock - ->expects(self::once()) - ->method('send'); - - $command = new UpsertOrder($orderId, $shopId); - $this->sut->upsertOrder($command); - } - - /** - * @test - */ - public function shouldNotUpsertOrderWhenConfigurationIsNotActive() - { - $orderId = 1; - $shopId = 1; - - $configurationDTOMock = $this->getMockWithoutConstructing(ConfigurationDto::class); - - $configurationDTOMock - ->expects(self::once()) - ->method('isEcommerceLiveSynchronizationActive') - ->willReturn(false); - - $configurationDTOMock - ->expects(self::never()) - ->method('getLiveSynchronizationUrl'); - - $this->configurationReadModelMock - ->expects(self::once()) - ->method('getConfigurationForShop') - ->with($shopId) - ->willReturn($configurationDTOMock); - - $this->messageSenderServiceMock - ->expects(self::never()) - ->method('send'); - - $command = new UpsertOrder($orderId, $shopId); - $this->sut->upsertOrder($command); - } -} diff --git a/tests/Unit/Ecommerce/Application/ProductServiceTest.php b/tests/Unit/Ecommerce/Application/ProductServiceTest.php deleted file mode 100644 index 4b76739..0000000 --- a/tests/Unit/Ecommerce/Application/ProductServiceTest.php +++ /dev/null @@ -1,132 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace GetResponse\Tests\Unit\Ecommerce\Application; - -use GetResponse\Configuration\ReadModel\ConfigurationDto; -use GetResponse\Configuration\ReadModel\ConfigurationReadModel; -use GetResponse\Ecommerce\Application\Command\UpsertProduct; -use GetResponse\Ecommerce\Application\ProductService; -use GetResponse\Ecommerce\DomainModel\Category; -use GetResponse\Ecommerce\DomainModel\Image; -use GetResponse\Ecommerce\DomainModel\Product; -use GetResponse\Ecommerce\DomainModel\Variant; -use GetResponse\MessageSender\Application\MessageSenderService; -use GetResponse\Tests\Unit\BaseTestCase; - -class ProductServiceTest extends BaseTestCase -{ - /** @var MessageSenderService|\PHPUnit_Framework_MockObject_MockObject */ - private $messageSenderMock; - /** @var ConfigurationReadModel|\PHPUnit_Framework_MockObject_MockObject */ - private $configurationReadModelMock; - /** @var ProductService */ - private $sut; - - public function setUp() - { - $this->messageSenderMock = $this->getMockWithoutConstructing(MessageSenderService::class); - $this->configurationReadModelMock = $this->getMockWithoutConstructing(ConfigurationReadModel::class); - - $this->sut = new ProductService($this->messageSenderMock, $this->configurationReadModelMock); - } - - /** - * @test - */ - public function shouldUpsertProduct() - { - $shopId = 1; - $productId = 2; - $languageId = 2; - $createdOn = '2020-01-05 12:45:22'; - $updatedOn = '2020-01-06 12:34:12'; - $status = 'publish'; - - $categories = [ - new Category(3, 1, 'Default category'), - ]; - - $images = [ - new Image('https://my-prestashop.com/img/p/2.jpg', 2), - ]; - - $variants = [ - new Variant( - 12, - 'Size - Size L', - 'test_product_1', - 19.99, - 19.99, - 29.99, - 29.99, - 100, - 'https://my-prestashop.com/product/2', - null, - null, - 'description short2', - 'description2', - $images, - $status - ), - ]; - - $productMock = new Product( - $productId, - 'Test Product2', - Product::CONFIGURABLE_TYPE, - 'https://my-prestashop.com/product/2', - 'VendorName', - $categories, - $variants, - $createdOn, - $updatedOn, - $status - ); - - $liveSynchronizationUrl = 'https://app.getreponse.com/callback/ecommerce/33983'; - - $configurationDTOMock = $this->getMockWithoutConstructing(ConfigurationDto::class); - - $configurationDTOMock - ->expects(self::once()) - ->method('isProductLiveSynchronizationActive') - ->willReturn(true); - - $configurationDTOMock - ->expects(self::once()) - ->method('getLiveSynchronizationUrl') - ->willReturn($liveSynchronizationUrl); - - $this->configurationReadModelMock - ->expects(self::once()) - ->method('getConfigurationForShop') - ->with($shopId) - ->willReturn($configurationDTOMock); - - $this->messageSenderMock - ->expects(self::once()) - ->method('send') - ->with($liveSynchronizationUrl, $productMock); - - $command = new UpsertProduct($shopId, $productId, $languageId); - $this->sut->upsertProduct($command); - } -} diff --git a/tests/Unit/Ecommerce/Application/RecommendationServiceTest.php b/tests/Unit/Ecommerce/Application/RecommendationServiceTest.php deleted file mode 100644 index ade598f..0000000 --- a/tests/Unit/Ecommerce/Application/RecommendationServiceTest.php +++ /dev/null @@ -1,141 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace GetResponse\Tests\Unit\Ecommerce\Application; - -use GetResponse\Ecommerce\Application\Adapter\ProductAdapter; -use GetResponse\Ecommerce\Application\Command\RecommendedProductCommand; -use GetResponse\Ecommerce\Application\RecommendationService; -use GetResponse\Ecommerce\DomainModel\Category; -use GetResponse\Ecommerce\DomainModel\Image; -use GetResponse\Ecommerce\DomainModel\Product; -use GetResponse\Ecommerce\DomainModel\RecommendedProduct; -use GetResponse\Ecommerce\DomainModel\Variant; -use GetResponse\Tests\Unit\BaseTestCase; -use PHPUnit\Framework\MockObject\MockObject; - -class RecommendationServiceTest extends BaseTestCase -{ - /** @var ProductAdapter|MockObject */ - private $productAdapterMock; - - public function setUp() - { - $this->productAdapterMock = $this->getMockWithoutConstructing(ProductAdapter::class); - - $this->sut = new RecommendationService($this->productAdapterMock); - } - - /** - * @test - */ - public function shouldCreateRecommendedProduct() - { - $productId = 123; - $languageId = 4; - $productUrl = 'https://my-prestashop.com/product/2'; - $price = '19.99'; - $previousPrice = '25.99'; - $sku = 'test_product_1'; - - $categories = [ - new Category(3, 1, 'Main category'), - new Category(3, 1, 'Sub category'), - ]; - - $images = [ - new Image('https://my-prestashop.com/img/p/2.jpg', 2), - ]; - $status = 'publish'; - - $variants = [ - new Variant( - 12, - 'Size - Size L', - $sku, - $price, - $price, - $previousPrice, - $previousPrice, - 10, - $productUrl, - null, - null, - 'description short2', - 'description2', - $images, - $status - ), - ]; - - $productMock = new Product( - $productId, - 'Test Product2', - Product::CONFIGURABLE_TYPE, - $productUrl, - 'VendorName', - $categories, - $variants, - '2023-06-01 12:00:01', - '2023-06-01 12:00:05', - $status - ); - - $this->productAdapterMock - ->expects(self::once()) - ->method('getProductById') - ->with($productId, $languageId) - ->willReturn($productMock); - - $command = new RecommendedProductCommand($productId, $languageId); - - $product = $this->sut->createRecommendedProduct($command); - - self::assertInstanceOf(RecommendedProduct::class, $product); - self::assertEquals($productUrl, $product->getUrl()); - self::assertEquals($productId, $product->getExternalId()); - self::assertEquals($price, $product->getPrice()); - self::assertEquals($previousPrice, $product->getPreviousPrice()); - self::assertEquals($sku, $product->getSku()); - } - - /** - * @test - * @dataProvider pageTypeProvider - */ - public function shouldReturnPageType($pageId, $expectedPageType) - { - $pageType = $this->sut->getPageType($pageId); - self::assertEquals($expectedPageType, $pageType); - } - - public function pageTypeProvider() - { - return [ - ['index', 'home'], - ['cart', 'cart'], - ['category', 'category'], - ['pagenotfound', 'error'], - ['product', 'product'], - ['notExistedPage', null], - [null, null], - ]; - } -} diff --git a/tests/Unit/Ecommerce/Application/index.php b/tests/Unit/Ecommerce/Application/index.php deleted file mode 100644 index 296d682..0000000 --- a/tests/Unit/Ecommerce/Application/index.php +++ /dev/null @@ -1,28 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -exit; diff --git a/tests/Unit/Ecommerce/DomainModel/RecommendedProductTest.php b/tests/Unit/Ecommerce/DomainModel/RecommendedProductTest.php deleted file mode 100644 index 8cdea1d..0000000 --- a/tests/Unit/Ecommerce/DomainModel/RecommendedProductTest.php +++ /dev/null @@ -1,94 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ - -namespace GetResponse\Tests\Unit\Ecommerce\DomainModel; - -use GetResponse\Ecommerce\DomainModel\RecommendedProduct; -use GetResponse\Tests\Unit\BaseTestCase; - -class RecommendedProductTest extends BaseTestCase -{ - /** - * @test - * @dataProvider recommendedProductProvider - */ - public function shouldReturnRecommendedProduct( - $url, - $externalId, - $name, - $price, - $imageUrl, - $description, - $category1, - $category2, - $sku, - $previousPrice - ) { - $expectedProductArray = [ - 'productUrl' => 'https://my-prestashop.com/product/1', - 'pageUrl' => 'https://my-prestashop.com/product/1', - 'productExternalId' => 3, - 'productName' => 'Test Product', - 'price' => 12.99, - 'imageUrl' => 'https://my-prestashop.com/product/image/1.jpg', - 'description' => 'This is productDescription', - 'category' => 'FirstCategory > SecondCategory', - 'available' => true, - 'sku' => 'product-sku', - 'attribute1' => 19.99, - 'attribute2' => null, - 'attribute3' => null, - 'attribute4' => null, - ]; - - $product = new RecommendedProduct($url, $externalId, $name, $price, $imageUrl, $description, [$category1, $category2], $sku, $previousPrice); - self::assertEquals($expectedProductArray, $product->toArray()); - } - - public function recommendedProductProvider() - { - return [ - [ - 'https://my-prestashop.com/product/1', - 3, - 'Test Product', - 12.99, - 'https://my-prestashop.com/product/image/1.jpg', - 'This is productDescription', - 'FirstCategory', - 'SecondCategory', - 'product-sku', - 19.99, - ], - [ - 'https://my-prestashop.com/product/1', - 3, - 'Test Product', - 12.98989, - 'https://my-prestashop.com/product/image/1.jpg', - 'This is

productDescription

\n', - 'FirstCategory', - 'SecondCategory', - 'product-sku', - 19.99000001, - ], - ]; - } -} diff --git a/tests/Unit/Ecommerce/DomainModel/index.php b/tests/Unit/Ecommerce/DomainModel/index.php deleted file mode 100644 index 296d682..0000000 --- a/tests/Unit/Ecommerce/DomainModel/index.php +++ /dev/null @@ -1,28 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -exit; diff --git a/tests/Unit/Ecommerce/index.php b/tests/Unit/Ecommerce/index.php deleted file mode 100644 index 296d682..0000000 --- a/tests/Unit/Ecommerce/index.php +++ /dev/null @@ -1,28 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -exit; diff --git a/tests/Unit/PrestashopMock/Address.php b/tests/Unit/PrestashopMock/Address.php deleted file mode 100644 index 009181f..0000000 --- a/tests/Unit/PrestashopMock/Address.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ -class Address -{ - /** @var int */ - public $id; - /** @var int */ - public $id_address_delivery; - /** @var int */ - public $id_address_invoice; - /** @var int */ - public $id_country; - /** @var int */ - public $id_state; - /** @var string */ - public $alias; - /** @var string */ - public $firstname; - /** @var string */ - public $lastname; - /** @var string */ - public $address1; - /** @var string */ - public $address2; - /** @var string */ - public $city; - /** @var string */ - public $postcode; - /** @var string */ - public $phone; - /** @var string */ - public $company; - - public function __construct($id) - { - $params = AddressParams::getAddressById($id); - $this->id = $params['id']; - $this->id_address_delivery = $params['id_address_delivery']; - $this->id_address_invoice = $params['id_address_invoice']; - $this->id_country = $params['id_country']; - $this->id_state = $params['id_state']; - $this->alias = $params['alias']; - $this->firstname = $params['firstname']; - $this->lastname = $params['lastname']; - $this->address1 = $params['address1']; - $this->address2 = $params['address2']; - $this->city = $params['city']; - $this->postcode = $params['postcode']; - $this->phone = $params['phone']; - $this->company = $params['company']; - } -} diff --git a/tests/Unit/PrestashopMock/Cart.php b/tests/Unit/PrestashopMock/Cart.php deleted file mode 100644 index 3e1d24c..0000000 --- a/tests/Unit/PrestashopMock/Cart.php +++ /dev/null @@ -1,78 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ -class Cart -{ - /** @var int */ - public $id; - /** @var int */ - public $id_shop; - /** @var int */ - public $id_customer; - /** @var int */ - public $id_currency; - /** @var float */ - public $total; - /** @var float */ - public $total_tax; - /** @var string */ - public $date_add; - /** @var string */ - public $date_upd; - /** @var array */ - public $products; - - public function __construct($id) - { - $params = CartParams::getCartById($id); - $this->id = $params['id']; - $this->id_shop = $params['id_shop']; - $this->id_customer = $params['id_customer']; - $this->id_currency = $params['id_currency']; - $this->total = $params['total']; - $this->total_tax = $params['total_tax']; - $this->date_add = $params['date_add']; - $this->date_upd = $params['date_upd']; - $this->products = $params['products']; - } - - /** - * @param bool $withTax - * - * @return float - */ - public function getOrderTotal($withTax) - { - if ($withTax) { - return $this->total_tax; - } - - return $this->total; - } - - /** - * @param bool $refresh - * - * @return array - */ - public function getProducts($refresh) - { - return $this->products; - } -} diff --git a/tests/Unit/PrestashopMock/Category.php b/tests/Unit/PrestashopMock/Category.php deleted file mode 100644 index 4547c7c..0000000 --- a/tests/Unit/PrestashopMock/Category.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ -class Category -{ - /** @var int */ - public $id; - /** @var int */ - public $id_parent; - /** @var string */ - public $name; - - public function __construct($id) - { - $params = CategoryParams::getCategoryById($id); - $this->id = $params['id']; - $this->id_parent = $params['id_parent']; - $this->name = $params['name']; - } -} diff --git a/tests/Unit/PrestashopMock/Combination.php b/tests/Unit/PrestashopMock/Combination.php deleted file mode 100644 index 1b2329e..0000000 --- a/tests/Unit/PrestashopMock/Combination.php +++ /dev/null @@ -1,33 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ -class Combination -{ - /** @var int */ - public $id; - /** @var string */ - public $reference; - - public function __construct($id) - { - $params = CombinationParams::getCombinationById($id); - $this->id = $params['id']; - $this->reference = $params['reference']; - } -} diff --git a/tests/Unit/PrestashopMock/Country.php b/tests/Unit/PrestashopMock/Country.php deleted file mode 100644 index 1555987..0000000 --- a/tests/Unit/PrestashopMock/Country.php +++ /dev/null @@ -1,33 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ -class Country -{ - /** @var int */ - public $id; - /** @var string */ - public $iso_code; - - public function __construct($id) - { - $params = CountryParams::getCountryById($id); - $this->id = $params['id']; - $this->iso_code = $params['iso_code']; - } -} diff --git a/tests/Unit/PrestashopMock/Currency.php b/tests/Unit/PrestashopMock/Currency.php deleted file mode 100644 index 416ce43..0000000 --- a/tests/Unit/PrestashopMock/Currency.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ -class Currency -{ - /** @var int */ - public $id; - /** @var string */ - public $iso_code; - - /** - * @param int $id - */ - public function __construct($id) - { - $params = CurrencyParams::getCurrencyById($id); - $this->id = $params['id']; - $this->iso_code = $params['iso_code']; - } -} diff --git a/tests/Unit/PrestashopMock/Customer.php b/tests/Unit/PrestashopMock/Customer.php deleted file mode 100644 index 768faff..0000000 --- a/tests/Unit/PrestashopMock/Customer.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ -class Customer -{ - /** @var int */ - public $id; - /** @var int */ - public $id_shop; - /** @var int */ - public $id_lang; - /** @var string */ - public $firstname; - /** @var string */ - public $lastname; - /** @var string */ - public $email; - /** @var bool */ - public $newsletter; - /** @var array */ - public $addresses; - /** @var string */ - public $birthday; - - /** - * @param int $id - */ - public function __construct($id) - { - $params = CustomerParams::getCustomerById($id); - $this->id = $params['id']; - $this->id_lang = $params['id_lang']; - $this->id_shop = $params['id_shop']; - $this->firstname = $params['firstname']; - $this->lastname = $params['lastname']; - $this->email = $params['email']; - $this->newsletter = $params['newsletter']; - $this->addresses = $params['addresses']; - $this->birthday = $params['birthday']; - } - - public function getAddresses($id_lang = null) - { - return $this->addresses; - } - - public static function getCustomersByEmail($email) - { - $customer = new self(1); - - return [$customer]; - } -} diff --git a/tests/Unit/PrestashopMock/Manufacturer.php b/tests/Unit/PrestashopMock/Manufacturer.php deleted file mode 100644 index 77362a8..0000000 --- a/tests/Unit/PrestashopMock/Manufacturer.php +++ /dev/null @@ -1,30 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ -class Manufacturer -{ - /** @var string */ - public $name; - - public function __construct($id) - { - $params = ManufacturerParams::getManufactureById($id); - $this->name = $params['name']; - } -} diff --git a/tests/Unit/PrestashopMock/MockParams/AddressParams.php b/tests/Unit/PrestashopMock/MockParams/AddressParams.php deleted file mode 100644 index 88680e5..0000000 --- a/tests/Unit/PrestashopMock/MockParams/AddressParams.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ -class AddressParams -{ - /** - * @var array - */ - private static $address = [ - 1 => [ - 'id' => 1, - 'alias' => 'home', - 'id_address_delivery' => 1, - 'id_address_invoice' => 1, - 'id_state' => 1, - 'id_country' => 1, - 'firstname' => 'John', - 'lastname' => 'Doe', - 'address1' => 'address1', - 'address2' => 'address2', - 'city' => 'city', - 'postcode' => 'postcode', - 'phone' => '544404400', - 'company' => 'company', - ], - ]; - - /** - * @param int $id - * - * @return array - */ - public static function getAddressById($id) - { - return static::$address[$id]; - } -} diff --git a/tests/Unit/PrestashopMock/MockParams/CartParams.php b/tests/Unit/PrestashopMock/MockParams/CartParams.php deleted file mode 100644 index dcc55e0..0000000 --- a/tests/Unit/PrestashopMock/MockParams/CartParams.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ -class CartParams -{ - /** - * @var array - */ - private static $cart = [ - 1 => [ - 'id' => 1, - 'id_shop' => 3, - 'id_customer' => 1, - 'id_currency' => 2, - 'total' => 29.99, - 'total_tax' => 34.43, - 'date_add' => '2020-05-12 11:43:59', - 'date_upd' => '2020-05-14 16:32:03', - 'products' => [ - [ - 'id_product' => 34, - 'quantity' => 1, - 'price' => 29.99, - 'price_wt' => 34.43, - 'reference' => 'product_34', - 'id_product_attribute' => 1, - ], - ], - ], - ]; - - /** - * @param int $id - * - * @return array - */ - public static function getCartById($id) - { - return static::$cart[$id]; - } -} diff --git a/tests/Unit/PrestashopMock/MockParams/CategoryParams.php b/tests/Unit/PrestashopMock/MockParams/CategoryParams.php deleted file mode 100644 index cf22c5d..0000000 --- a/tests/Unit/PrestashopMock/MockParams/CategoryParams.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ -class CategoryParams -{ - /** - * @var array - */ - private static $category = [ - 3 => [ - 'id' => 3, - 'id_parent' => 1, - 'name' => 'Default category', - ], - ]; - - /** - * @param int $id - * - * @return array - */ - public static function getCategoryById($id) - { - return static::$category[$id]; - } -} diff --git a/tests/Unit/PrestashopMock/MockParams/CombinationParams.php b/tests/Unit/PrestashopMock/MockParams/CombinationParams.php deleted file mode 100644 index bb3edd7..0000000 --- a/tests/Unit/PrestashopMock/MockParams/CombinationParams.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ -class CombinationParams -{ - /** - * @var array - */ - private static $combination = [ - 1 => [ - 'id' => 1, - 'reference' => 'product_combination_1', - 'quantity' => 100, - ], - ]; - - /** - * @param int $id - * - * @return array - */ - public static function getCombinationById($id) - { - return static::$combination[$id]; - } -} diff --git a/tests/Unit/PrestashopMock/MockParams/CountryParams.php b/tests/Unit/PrestashopMock/MockParams/CountryParams.php deleted file mode 100644 index 1755b07..0000000 --- a/tests/Unit/PrestashopMock/MockParams/CountryParams.php +++ /dev/null @@ -1,41 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ -class CountryParams -{ - /** - * @var array - */ - private static $country = [ - 1 => [ - 'id' => 1, - 'iso_code' => 'pl', - ], - ]; - - /** - * @param int $id - * - * @return array - */ - public static function getCountryById($id) - { - return static::$country[$id]; - } -} diff --git a/tests/Unit/PrestashopMock/MockParams/CurrencyParams.php b/tests/Unit/PrestashopMock/MockParams/CurrencyParams.php deleted file mode 100644 index 27b020d..0000000 --- a/tests/Unit/PrestashopMock/MockParams/CurrencyParams.php +++ /dev/null @@ -1,39 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ -class CurrencyParams -{ - /** - * @var array - */ - private static $currency = [ - 1 => ['id' => 1, 'iso_code' => 'pln'], - 2 => ['id' => 2, 'iso_code' => 'eur'], - ]; - - /** - * @param int $id - * - * @return array - */ - public static function getCurrencyById($id) - { - return static::$currency[$id]; - } -} diff --git a/tests/Unit/PrestashopMock/MockParams/CustomerParams.php b/tests/Unit/PrestashopMock/MockParams/CustomerParams.php deleted file mode 100644 index 964ea66..0000000 --- a/tests/Unit/PrestashopMock/MockParams/CustomerParams.php +++ /dev/null @@ -1,87 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ -class CustomerParams -{ - /** - * @var array - */ - private static $customer = [ - 1 => [ - 'id' => 1, - 'id_shop' => 2, - 'id_lang' => 2, - 'firstname' => 'John', - 'lastname' => 'Doe', - 'email' => 'john.doe@example.com', - 'newsletter' => true, - 'birthday' => '1987-09-04', - 'addresses' => [ - [ - 'alias' => 'home', - 'country' => 'Poland', - 'firstname' => 'John', - 'lastname' => 'Doe', - 'address1' => 'Street 1', - 'address2' => '', - 'city' => 'City', - 'postcode' => 'PostCode', - 'state' => 'State', - 'phone' => '544 404 400', - 'company' => '', - ], - ], - ], - 2 => [ - 'id' => 2, - 'id_shop' => 1, - 'id_lang' => 1, - 'firstname' => 'Mark', - 'lastname' => 'Smith', - 'email' => 'mark.smith@example.com', - 'newsletter' => false, - 'birthday' => '1992-04-21', - 'addresses' => [ - [ - 'alias' => 'home', - 'country' => 'Poland', - 'firstname' => 'Mark', - 'lastname' => 'Smith', - 'address1' => 'Street 1', - 'address2' => '', - 'city' => 'City', - 'postcode' => 'PostCode', - 'state' => 'State', - 'phone' => '544 404 400', - 'company' => '', - ], - ], - ], - ]; - - /** - * @param int $id - * - * @return array - */ - public static function getCustomerById($id) - { - return static::$customer[$id]; - } -} diff --git a/tests/Unit/PrestashopMock/MockParams/ImageParams.php b/tests/Unit/PrestashopMock/MockParams/ImageParams.php deleted file mode 100644 index 7eb44ba..0000000 --- a/tests/Unit/PrestashopMock/MockParams/ImageParams.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ -class ImageParams -{ - /** - * @var array - */ - private static $image = [ - 1 => [ - 'id' => 1, - 'position' => 1, - ], - 2 => [ - 'id' => 2, - 'position' => 2, - ], - ]; - - /** - * @param int $id - * - * @return array - */ - public static function getImageById($id) - { - return static::$image[$id]; - } -} diff --git a/tests/Unit/PrestashopMock/MockParams/ManufacturerParams.php b/tests/Unit/PrestashopMock/MockParams/ManufacturerParams.php deleted file mode 100644 index 92fc993..0000000 --- a/tests/Unit/PrestashopMock/MockParams/ManufacturerParams.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ -class ManufacturerParams -{ - /** - * @var array - */ - private static $address = [ - 1 => [ - 'name' => 'VendorName', - ], - ]; - - /** - * @param int $id - * - * @return array - */ - public static function getManufactureById($id) - { - return static::$address[$id]; - } -} diff --git a/tests/Unit/PrestashopMock/MockParams/OrderParams.php b/tests/Unit/PrestashopMock/MockParams/OrderParams.php deleted file mode 100644 index d39e421..0000000 --- a/tests/Unit/PrestashopMock/MockParams/OrderParams.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ -class OrderParams -{ - /** - * @var array - */ - private static $order = [ - 1 => [ - 'id' => 1, - 'id_customer' => 1, - 'id_currency' => 1, - 'id_address_delivery' => 1, - 'id_address_invoice' => 1, - 'reference' => 'WD32X98', - 'id_cart' => 1, - 'products' => [], - 'total_paid_tax_excl' => 9.99, - 'total_paid_tax_incl' => 12.33, - 'total_shipping_tax_incl' => 5.00, - 'current_state' => 2, - 'id_lang' => 1, - 'date_add' => '2020-03-12', - 'date_upd' => '2020-03-15', - ], - ]; - - /** - * @param int $id - * - * @return array - */ - public static function getOrderById($id) - { - return static::$order[$id]; - } -} diff --git a/tests/Unit/PrestashopMock/MockParams/OrderStateParams.php b/tests/Unit/PrestashopMock/MockParams/OrderStateParams.php deleted file mode 100644 index bc15a40..0000000 --- a/tests/Unit/PrestashopMock/MockParams/OrderStateParams.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ -class OrderStateParams -{ - /** - * @var array - */ - private static $orderState = [ - 1 => [ - 'id' => 1, - 'name' => 'state1', - ], - 2 => [ - 'id' => 2, - 'name' => 'state2', - ], - ]; - - /** - * @param int $id - * - * @return array - */ - public static function getOrderStateById($id) - { - return static::$orderState[$id]; - } -} diff --git a/tests/Unit/PrestashopMock/MockParams/ProductParams.php b/tests/Unit/PrestashopMock/MockParams/ProductParams.php deleted file mode 100644 index cfbb285..0000000 --- a/tests/Unit/PrestashopMock/MockParams/ProductParams.php +++ /dev/null @@ -1,109 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ -class ProductParams -{ - /** - * @var array - */ - private static $product = [ - 1 => [ - 'id' => 1, - 'name' => [1 => 'Test Product', 2 => 'Test Product2'], - 'images' => [ - [ - 'id_image' => 2, - 'position' => 1, - ], - ], - 'categories' => [3], - 'hasAttributes' => false, - 'link_rewrite' => [1 => 'link_rewrite', 2 => 'link_rewrite2'], - 'price' => 19.99, - 'priceWithoutReduct' => 29.99, - 'attributeCombinations' => [ - [ - 'id_product_attribute' => 12, - 'group_name' => 'Size', - 'attribute_name' => 'Size L', - 'quantity' => 10, - 'reference' => 'test_product_1', - ], - ], - 'reference' => 'test_product_1', - 'quantity' => 10, - 'description_short' => [1 => 'description short', 2 => 'description short2'], - 'description' => [1 => 'description', 2 => 'description2'], - 'date_add' => '2020-01-05 12:45:22', - 'date_upd' => '2020-01-06 12:34:12', - 'id_manufacturer' => 1, - 'active' => '1', - 'wsStockAvailables' => [ - ['id' => '12', 'id_product_attribute' => '0'], - ['id' => '13', 'id_product_attribute' => '12'], - ], - ], - 2 => [ - 'id' => 2, - 'name' => [1 => 'Test Product', 2 => 'Test Product2'], - 'images' => [ - [ - 'id_image' => 2, - 'position' => 1, - ], - ], - 'categories' => [3], - 'hasAttributes' => true, - 'link_rewrite' => [1 => 'link_rewrite', 2 => 'link_rewrite2'], - 'price' => 19.99, - 'priceWithoutReduct' => 29.99, - 'attributeCombinations' => [ - [ - 'id_product_attribute' => 12, - 'group_name' => 'Size', - 'attribute_name' => 'Size L', - 'quantity' => 10, - 'reference' => 'test_product_1', - ], - ], - 'reference' => 'test_product_1', - 'quantity' => 10, - 'description_short' => [1 => 'description short', 2 => 'description short2'], - 'description' => [1 => 'description', 2 => 'description2'], - 'date_add' => '2020-01-05 12:45:22', - 'date_upd' => '2020-01-06 12:34:12', - 'id_manufacturer' => 1, - 'active' => '1', - 'wsStockAvailables' => [ - ['id' => '12', 'id_product_attribute' => '0'], - ['id' => '13', 'id_product_attribute' => '12'], - ], - ], - ]; - - /** - * @param int $id - * - * @return array - */ - public static function getProductById($id) - { - return static::$product[$id]; - } -} diff --git a/tests/Unit/PrestashopMock/MockParams/ShopParams.php b/tests/Unit/PrestashopMock/MockParams/ShopParams.php deleted file mode 100644 index ddb1dfb..0000000 --- a/tests/Unit/PrestashopMock/MockParams/ShopParams.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ -class ShopParams -{ - /** - * @var array - */ - private static $shop = [ - 1 => ['id' => 1], - ]; - - /** - * @param int $id - * - * @return array - */ - public static function getShopById($id) - { - return static::$shop[$id]; - } -} diff --git a/tests/Unit/PrestashopMock/MockParams/StateParams.php b/tests/Unit/PrestashopMock/MockParams/StateParams.php deleted file mode 100644 index 78bb369..0000000 --- a/tests/Unit/PrestashopMock/MockParams/StateParams.php +++ /dev/null @@ -1,41 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ -class StateParams -{ - /** - * @var array - */ - private static $state = [ - 1 => [ - 'id' => 1, - 'name' => 'state', - ], - ]; - - /** - * @param int $id - * - * @return array - */ - public static function getStateById($id) - { - return static::$state[$id]; - } -} diff --git a/tests/Unit/PrestashopMock/MockParams/StockAvailableParams.php b/tests/Unit/PrestashopMock/MockParams/StockAvailableParams.php deleted file mode 100644 index 8621e2d..0000000 --- a/tests/Unit/PrestashopMock/MockParams/StockAvailableParams.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ -class StockAvailableParams -{ - /** - * @var array - */ - private static $stockAvailable = [ - 12 => [ - 'id' => 12, - 'quantity' => 100, - ], - 13 => [ - 'id' => 13, - 'quantity' => 100, - ], - ]; - - /** - * @param int $id - * - * @return array - */ - public static function getStockAvailableById($id) - { - return static::$stockAvailable[$id]; - } -} diff --git a/tests/Unit/PrestashopMock/MockParams/index.php b/tests/Unit/PrestashopMock/MockParams/index.php deleted file mode 100644 index 296d682..0000000 --- a/tests/Unit/PrestashopMock/MockParams/index.php +++ /dev/null @@ -1,28 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -exit; diff --git a/tests/Unit/PrestashopMock/Order.php b/tests/Unit/PrestashopMock/Order.php deleted file mode 100644 index b7af4ca..0000000 --- a/tests/Unit/PrestashopMock/Order.php +++ /dev/null @@ -1,87 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ -class Order -{ - /** @var int */ - public $id; - /** @var int */ - public $id_address_delivery; - /** @var int */ - public $id_address_invoice; - /** @var int */ - public $id_customer; - /** @var int */ - public $id_currency; - /** @var string */ - public $reference; - /** @var int */ - public $id_cart; - /** @var array */ - public $products; - /** @var float */ - public $total_paid_tax_excl; - /** @var float */ - public $total_paid_tax_incl; - /** @var float */ - public $total_shipping_tax_incl; - /** @var int */ - public $current_state; - /** @var int */ - public $id_lang; - /** @var string */ - public $date_add; - /** @var string */ - public $date_upd; - - public function __construct($id) - { - $params = OrderParams::getOrderById($id); - $this->id = $params['id']; - $this->id_customer = $params['id_customer']; - $this->id_address_delivery = $params['id_address_delivery']; - $this->id_address_invoice = $params['id_address_invoice']; - $this->id_currency = $params['id_currency']; - $this->reference = $params['reference']; - $this->id_cart = $params['id_cart']; - $this->products = $params['products']; - $this->total_paid_tax_excl = $params['total_paid_tax_excl']; - $this->total_shipping_tax_incl = $params['total_shipping_tax_incl']; - $this->current_state = $params['current_state']; - $this->id_lang = $params['id_lang']; - $this->date_add = $params['date_add']; - $this->date_upd = $params['date_upd']; - } - - /** - * @return array - */ - public function getProducts() - { - return $this->products; - } - - /** - * @return int - */ - public function getCurrentState() - { - return $this->current_state; - } -} diff --git a/tests/Unit/PrestashopMock/OrderState.php b/tests/Unit/PrestashopMock/OrderState.php deleted file mode 100644 index 6fcd153..0000000 --- a/tests/Unit/PrestashopMock/OrderState.php +++ /dev/null @@ -1,33 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ -class OrderState -{ - /** @var int */ - public $id; - /** @var string */ - public $name; - - public function __construct($id) - { - $params = OrderStateParams::getOrderStateById($id); - $this->id = $params['id']; - $this->name = $params['name']; - } -} diff --git a/tests/Unit/PrestashopMock/Product.php b/tests/Unit/PrestashopMock/Product.php deleted file mode 100644 index e43af42..0000000 --- a/tests/Unit/PrestashopMock/Product.php +++ /dev/null @@ -1,116 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ -class Product -{ - /** @var int */ - public $id; - /** @var string */ - public $name; - /** @var array */ - public $images; - /** @var array */ - public $categories; - /** @var int */ - public $hasAttributes; - /** @var array */ - public $attributeCombinations; - /** @var string */ - public $link_rewrite; - /** @var float */ - public $price; - /** @var float */ - public $priceWithoutReduct; - /** @var string */ - public $reference; - /** @var int */ - public $quantity; - /** @var string */ - public $description_short; - /** @var string */ - public $description; - /** @var string */ - public $date_add; - /** @var string */ - public $date_upd; - /** @var string */ - public $id_manufacturer; - /** @var string */ - public $active; - /** @var array */ - private $wsStockAvailables; - - public function __construct($id) - { - $params = ProductParams::getProductById($id); - $this->id = $params['id']; - $this->name = $params['name']; - $this->images = $params['images']; - $this->categories = $params['categories']; - $this->hasAttributes = $params['hasAttributes']; - $this->attributeCombinations = $params['attributeCombinations']; - $this->link_rewrite = $params['link_rewrite']; - $this->price = $params['price']; - $this->priceWithoutReduct = $params['priceWithoutReduct']; - $this->reference = $params['reference']; - $this->quantity = $params['quantity']; - $this->description_short = $params['description_short']; - $this->description = $params['description']; - $this->date_add = $params['date_add']; - $this->date_upd = $params['date_upd']; - $this->id_manufacturer = $params['id_manufacturer']; - $this->active = $params['active']; - $this->wsStockAvailables = $params['wsStockAvailables']; - } - - public function getImages($languageId) - { - return $this->images; - } - - public function getCategories() - { - return $this->categories; - } - - public function hasAttributes() - { - return $this->hasAttributes; - } - - public function getAttributeCombinations() - { - return $this->attributeCombinations; - } - - public function getPrice() - { - return $this->price; - } - - public function getWsStockAvailables() - { - return $this->wsStockAvailables; - } - - public function getPriceWithoutReduct($withTax = false) - { - return $this->priceWithoutReduct; - } -} diff --git a/tests/Unit/PrestashopMock/State.php b/tests/Unit/PrestashopMock/State.php deleted file mode 100644 index 97d9c54..0000000 --- a/tests/Unit/PrestashopMock/State.php +++ /dev/null @@ -1,33 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ -class State -{ - /** @var int */ - public $id; - /** @var string */ - public $name; - - public function __construct($id) - { - $params = StateParams::getStateById($id); - $this->id = $params['id']; - $this->name = $params['name']; - } -} diff --git a/tests/Unit/PrestashopMock/StockAvailableCore.php b/tests/Unit/PrestashopMock/StockAvailableCore.php deleted file mode 100644 index 03b91dd..0000000 --- a/tests/Unit/PrestashopMock/StockAvailableCore.php +++ /dev/null @@ -1,30 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ -class StockAvailableCore -{ - /** @var string */ - public $quantity; - - public function __construct($id) - { - $params = StockAvailableParams::getStockAvailableById($id); - $this->quantity = $params['quantity']; - } -} diff --git a/tests/Unit/PrestashopMock/index.php b/tests/Unit/PrestashopMock/index.php deleted file mode 100644 index 296d682..0000000 --- a/tests/Unit/PrestashopMock/index.php +++ /dev/null @@ -1,28 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -exit; diff --git a/tests/Unit/index.php b/tests/Unit/index.php deleted file mode 100644 index 296d682..0000000 --- a/tests/Unit/index.php +++ /dev/null @@ -1,28 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -exit; diff --git a/tests/bootstrap.php b/tests/bootstrap.php deleted file mode 100755 index f187d6b..0000000 --- a/tests/bootstrap.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ -require_once __DIR__ . '/Unit/PrestashopMock/Customer.php'; -require_once __DIR__ . '/Unit/PrestashopMock/MockParams/CustomerParams.php'; -require_once __DIR__ . '/Unit/PrestashopMock/Currency.php'; -require_once __DIR__ . '/Unit/PrestashopMock/MockParams/CurrencyParams.php'; -require_once __DIR__ . '/Unit/PrestashopMock/Cart.php'; -require_once __DIR__ . '/Unit/PrestashopMock/MockParams/CartParams.php'; -require_once __DIR__ . '/Unit/PrestashopMock/Product.php'; -require_once __DIR__ . '/Unit/PrestashopMock/MockParams/ProductParams.php'; -require_once __DIR__ . '/Unit/PrestashopMock/Shop.php'; -require_once __DIR__ . '/Unit/PrestashopMock/MockParams/ShopParams.php'; -require_once __DIR__ . '/Unit/PrestashopMock/Link.php'; -require_once __DIR__ . '/Unit/PrestashopMock/Category.php'; -require_once __DIR__ . '/Unit/PrestashopMock/MockParams/CategoryParams.php'; -require_once __DIR__ . '/Unit/PrestashopMock/Image.php'; -require_once __DIR__ . '/Unit/PrestashopMock/MockParams/ImageParams.php'; -require_once __DIR__ . '/Unit/PrestashopMock/ImageType.php'; -require_once __DIR__ . '/Unit/PrestashopMock/Tools.php'; -require_once __DIR__ . '/Unit/PrestashopMock/Order.php'; -require_once __DIR__ . '/Unit/PrestashopMock/MockParams/OrderParams.php'; -require_once __DIR__ . '/Unit/PrestashopMock/Address.php'; -require_once __DIR__ . '/Unit/PrestashopMock/MockParams/AddressParams.php'; -require_once __DIR__ . '/Unit/PrestashopMock/Country.php'; -require_once __DIR__ . '/Unit/PrestashopMock/MockParams/CountryParams.php'; -require_once __DIR__ . '/Unit/PrestashopMock/State.php'; -require_once __DIR__ . '/Unit/PrestashopMock/MockParams/StateParams.php'; -require_once __DIR__ . '/Unit/PrestashopMock/OrderState.php'; -require_once __DIR__ . '/Unit/PrestashopMock/MockParams/OrderStateParams.php'; -require_once __DIR__ . '/Unit/PrestashopMock/Combination.php'; -require_once __DIR__ . '/Unit/PrestashopMock/MockParams/CombinationParams.php'; -require_once __DIR__ . '/Unit/PrestashopMock/Tools.php'; -require_once __DIR__ . '/Unit/PrestashopMock/MockParams/ManufacturerParams.php'; -require_once __DIR__ . '/Unit/PrestashopMock/Manufacturer.php'; -require_once __DIR__ . '/Unit/PrestashopMock/MockParams/StockAvailableParams.php'; -require_once __DIR__ . '/Unit/PrestashopMock/StockAvailableCore.php'; -require_once __DIR__ . '/Unit/PrestashopMock/Context.php'; - -define('__PS_BASE_URI__', 'https://my-prestashop.com/'); -define('_PS_BASE_URL_', 'https://my-prestashop.com/'); -define('_PS_VERSION_', '1.6.1.0'); -define('_THEME_PROD_DIR_', 'img/p/'); diff --git a/tests/index.php b/tests/index.php deleted file mode 100644 index 296d682..0000000 --- a/tests/index.php +++ /dev/null @@ -1,28 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 - */ -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -exit; diff --git a/tests/phpunit.xml b/tests/phpunit.xml deleted file mode 100755 index a161bbd..0000000 --- a/tests/phpunit.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - Unit - - - - - ../src - - - diff --git a/tests/Unit/PrestashopMock/ImageType.php b/translations/en.php similarity index 84% rename from tests/Unit/PrestashopMock/ImageType.php rename to translations/en.php index d63f48c..c09cd3c 100644 --- a/tests/Unit/PrestashopMock/ImageType.php +++ b/translations/en.php @@ -17,9 +17,8 @@ * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -class ImageType -{ - public static function getFormatedName($name) - { - } -} + + +global $_MODULE; +$_MODULE = []; +$_MODULE['<{grprestashop}prestashop>cartrecovery_8667e2738fda398dc435804735e06344'] = 'We could not recover your cart.'; diff --git a/tests/Unit/Contact/Application/Adapter/index.php b/translations/index.php similarity index 74% rename from tests/Unit/Contact/Application/Adapter/index.php rename to translations/index.php index 296d682..74851d7 100644 --- a/tests/Unit/Contact/Application/Adapter/index.php +++ b/translations/index.php @@ -17,12 +17,14 @@ * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); -header('Location: ../'); +header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); +header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); + +header("Cache-Control: no-store, no-cache, must-revalidate"); +header("Cache-Control: post-check=0, pre-check=0", false); +header("Pragma: no-cache"); + +header("Location: ../"); exit; diff --git a/tests/Unit/PrestashopMock/Shop.php b/translations/pl.php similarity index 81% rename from tests/Unit/PrestashopMock/Shop.php rename to translations/pl.php index 7e68f17..64a461a 100644 --- a/tests/Unit/PrestashopMock/Shop.php +++ b/translations/pl.php @@ -17,14 +17,8 @@ * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 */ -class Shop -{ - /** @var int */ - public $id; - public function __construct($id) - { - $params = ShopParams::getShopById($id); - $this->id = $params['id']; - } -} + +global $_MODULE; +$_MODULE = []; +$_MODULE['<{grprestashop}prestashop>cartrecovery_8667e2738fda398dc435804735e06344'] = 'Nie udało się odtworzyć koszyka.';