From cc4e8c9c5bff879e7b840f2caa4008a7287e7640 Mon Sep 17 00:00:00 2001 From: Akolzin Dmitry Date: Tue, 25 Feb 2020 13:45:17 +0300 Subject: [PATCH 01/26] update build --- .travis.yml | 42 ++++++++----------- Makefile | 15 +++++++ phpunit.xml.dist | 2 +- resources/bin/pot_compile.sh | 5 --- tests/bin/script.sh | 8 ---- tests/{phpunit => }/bootstrap.php | 0 .../test-wc-retailcrm-customer-address.php | 0 .../order/test-wc-retailcrm-order-address.php | 0 .../order/test-wc-retailcrm-order-item.php | 0 .../order/test-wc-retailcrm-order-payment.php | 0 .../{phpunit => }/test-wc-retailcrm-base.php | 0 .../test-wc-retailcrm-customers.php | 0 .../test-wc-retailcrm-daemon-collector.php | 0 tests/{phpunit => }/test-wc-retailcrm-ga.php | 0 .../test-wc-retailcrm-history.php | 0 .../test-wc-retailcrm-inventories.php | 0 .../test-wc-retailcrm-orders.php | 0 .../test-wc-retailcrm-plugin.php | 0 18 files changed, 33 insertions(+), 39 deletions(-) delete mode 100755 resources/bin/pot_compile.sh delete mode 100644 tests/bin/script.sh rename tests/{phpunit => }/bootstrap.php (100%) rename tests/{phpunit => }/customer/test-wc-retailcrm-customer-address.php (100%) rename tests/{phpunit => }/order/test-wc-retailcrm-order-address.php (100%) rename tests/{phpunit => }/order/test-wc-retailcrm-order-item.php (100%) rename tests/{phpunit => }/order/test-wc-retailcrm-order-payment.php (100%) rename tests/{phpunit => }/test-wc-retailcrm-base.php (100%) rename tests/{phpunit => }/test-wc-retailcrm-customers.php (100%) rename tests/{phpunit => }/test-wc-retailcrm-daemon-collector.php (100%) rename tests/{phpunit => }/test-wc-retailcrm-ga.php (100%) rename tests/{phpunit => }/test-wc-retailcrm-history.php (100%) rename tests/{phpunit => }/test-wc-retailcrm-inventories.php (100%) rename tests/{phpunit => }/test-wc-retailcrm-orders.php (100%) rename tests/{phpunit => }/test-wc-retailcrm-plugin.php (100%) diff --git a/.travis.yml b/.travis.yml index db239f2..6296842 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,34 +1,26 @@ -language: php - +os: linux dist: trusty -sudo: false +language: php -php: - - 5.6 - - 7.0 - - 7.1 +if: tag IS blank -env: - - WP_VERSION=latest WP_MULTISITE=0 - -matrix: - fast_finish: true - include: - - php: 7.2 - env: WP_VERSION=latest WP_MULTISITE=0 RUN_PHPCS=1 +stages: + - test + - deploy before_script: - bash tests/bin/install.sh wc_retailcrm_test root '' localhost $WP_VERSION -script: - - bash tests/bin/script.sh +script: make tests -deploy: - skip_cleanup: true - provider: script - script: make - on: - php: 7.2 - branch: master - condition: "$DEPLOY = true" +jobs: + include: + - php: 5.6 + env: WP_VERSION=latest WP_MULTISITE=0 + - stage: deploy + deploy: + cleanup: false + provider: script + script: make + if: branch = master AND type = push AND fork = false \ No newline at end of file diff --git a/Makefile b/Makefile index 59a6dd0..b0e6d02 100644 --- a/Makefile +++ b/Makefile @@ -20,3 +20,18 @@ svn_push: /tmp/svn_plugin_dir remove_dir: rm -rf /tmp/svn_plugin_dir + +compile_pot: + msgfmt resources/pot/retailcrm-ru_RU.pot -o src/languages/retailcrm-ru_RU.mo + msgfmt resources/pot/retailcrm-es_ES.pot -o src/languages/retailcrm-es_ES.mo + +install: + bash tests/bin/install.sh + composer install + +tests: install +ifeq ($(USE_COMPOSER),1) + vendor/phpunit/phpunit/phpunit -c phpunit.xml.dist +else + phpunit -c phpunit.xml.dist +endif \ No newline at end of file diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 8057fd7..44f2477 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -13,7 +13,7 @@ > - tests/phpunit + tests diff --git a/resources/bin/pot_compile.sh b/resources/bin/pot_compile.sh deleted file mode 100755 index db6e82f..0000000 --- a/resources/bin/pot_compile.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -DIRECTORY=$(cd `dirname $0` && pwd) - -msgfmt $DIRECTORY/../pot/retailcrm-ru_RU.pot -o $DIRECTORY/../../src/languages/retailcrm-ru_RU.mo -msgfmt $DIRECTORY/../pot/retailcrm-es_ES.pot -o $DIRECTORY/../../src/languages/retailcrm-es_ES.mo \ No newline at end of file diff --git a/tests/bin/script.sh b/tests/bin/script.sh deleted file mode 100644 index f92901b..0000000 --- a/tests/bin/script.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -if [[ ${RUN_PHPCS} == 1 ]]; then - composer install - vendor/phpunit/phpunit/phpunit -c phpunit.xml.dist -else - phpunit -c phpunit.xml.dist -fi diff --git a/tests/phpunit/bootstrap.php b/tests/bootstrap.php similarity index 100% rename from tests/phpunit/bootstrap.php rename to tests/bootstrap.php diff --git a/tests/phpunit/customer/test-wc-retailcrm-customer-address.php b/tests/customer/test-wc-retailcrm-customer-address.php similarity index 100% rename from tests/phpunit/customer/test-wc-retailcrm-customer-address.php rename to tests/customer/test-wc-retailcrm-customer-address.php diff --git a/tests/phpunit/order/test-wc-retailcrm-order-address.php b/tests/order/test-wc-retailcrm-order-address.php similarity index 100% rename from tests/phpunit/order/test-wc-retailcrm-order-address.php rename to tests/order/test-wc-retailcrm-order-address.php diff --git a/tests/phpunit/order/test-wc-retailcrm-order-item.php b/tests/order/test-wc-retailcrm-order-item.php similarity index 100% rename from tests/phpunit/order/test-wc-retailcrm-order-item.php rename to tests/order/test-wc-retailcrm-order-item.php diff --git a/tests/phpunit/order/test-wc-retailcrm-order-payment.php b/tests/order/test-wc-retailcrm-order-payment.php similarity index 100% rename from tests/phpunit/order/test-wc-retailcrm-order-payment.php rename to tests/order/test-wc-retailcrm-order-payment.php diff --git a/tests/phpunit/test-wc-retailcrm-base.php b/tests/test-wc-retailcrm-base.php similarity index 100% rename from tests/phpunit/test-wc-retailcrm-base.php rename to tests/test-wc-retailcrm-base.php diff --git a/tests/phpunit/test-wc-retailcrm-customers.php b/tests/test-wc-retailcrm-customers.php similarity index 100% rename from tests/phpunit/test-wc-retailcrm-customers.php rename to tests/test-wc-retailcrm-customers.php diff --git a/tests/phpunit/test-wc-retailcrm-daemon-collector.php b/tests/test-wc-retailcrm-daemon-collector.php similarity index 100% rename from tests/phpunit/test-wc-retailcrm-daemon-collector.php rename to tests/test-wc-retailcrm-daemon-collector.php diff --git a/tests/phpunit/test-wc-retailcrm-ga.php b/tests/test-wc-retailcrm-ga.php similarity index 100% rename from tests/phpunit/test-wc-retailcrm-ga.php rename to tests/test-wc-retailcrm-ga.php diff --git a/tests/phpunit/test-wc-retailcrm-history.php b/tests/test-wc-retailcrm-history.php similarity index 100% rename from tests/phpunit/test-wc-retailcrm-history.php rename to tests/test-wc-retailcrm-history.php diff --git a/tests/phpunit/test-wc-retailcrm-inventories.php b/tests/test-wc-retailcrm-inventories.php similarity index 100% rename from tests/phpunit/test-wc-retailcrm-inventories.php rename to tests/test-wc-retailcrm-inventories.php diff --git a/tests/phpunit/test-wc-retailcrm-orders.php b/tests/test-wc-retailcrm-orders.php similarity index 100% rename from tests/phpunit/test-wc-retailcrm-orders.php rename to tests/test-wc-retailcrm-orders.php diff --git a/tests/phpunit/test-wc-retailcrm-plugin.php b/tests/test-wc-retailcrm-plugin.php similarity index 100% rename from tests/phpunit/test-wc-retailcrm-plugin.php rename to tests/test-wc-retailcrm-plugin.php From 9018d547af1237b833deaecf8a92078fe35e56a8 Mon Sep 17 00:00:00 2001 From: Akolzin Dmitry Date: Tue, 25 Feb 2020 13:56:08 +0300 Subject: [PATCH 02/26] update travis config --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 6296842..1003dce 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,7 @@ stages: - deploy before_script: + - nvm install 10 - bash tests/bin/install.sh wc_retailcrm_test root '' localhost $WP_VERSION script: make tests From a18de2625ef6f0b7bbd8b86ee2c3ed261654078d Mon Sep 17 00:00:00 2001 From: Akolzin Dmitry Date: Tue, 25 Feb 2020 14:00:08 +0300 Subject: [PATCH 03/26] update Makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b0e6d02..66eedd6 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ compile_pot: msgfmt resources/pot/retailcrm-es_ES.pot -o src/languages/retailcrm-es_ES.mo install: - bash tests/bin/install.sh + bash tests/bin/install.sh wc_retailcrm_test root '' localhost $(WP_VERSION) composer install tests: install From da07d142acee94a66c7e5b2702b133c54a816ae6 Mon Sep 17 00:00:00 2001 From: Akolzin Dmitry Date: Tue, 25 Feb 2020 14:05:51 +0300 Subject: [PATCH 04/26] fix Makefile --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1003dce..3175978 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ stages: before_script: - nvm install 10 - - bash tests/bin/install.sh wc_retailcrm_test root '' localhost $WP_VERSION + - make install script: make tests From 239c5d43a8dc26e8e9c0cf3d28ae82b1435636ec Mon Sep 17 00:00:00 2001 From: Akolzin Dmitry Date: Tue, 25 Feb 2020 14:26:27 +0300 Subject: [PATCH 05/26] fix Makefile --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 66eedd6..3097329 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,9 @@ compile_pot: install: bash tests/bin/install.sh wc_retailcrm_test root '' localhost $(WP_VERSION) +ifeq ($(USE_COMPOSER),1) composer install +endif tests: install ifeq ($(USE_COMPOSER),1) From 3c0f0530282ab5ee60d96f07ef3aeeb4848cd930 Mon Sep 17 00:00:00 2001 From: Akolzin Dmitry Date: Tue, 25 Feb 2020 14:30:38 +0300 Subject: [PATCH 06/26] fix Makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 3097329..e9345c2 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,7 @@ ifeq ($(USE_COMPOSER),1) composer install endif -tests: install +tests: ifeq ($(USE_COMPOSER),1) vendor/phpunit/phpunit/phpunit -c phpunit.xml.dist else From 68522a8e7e03111665bade0e988b871a40a2ca5c Mon Sep 17 00:00:00 2001 From: Akolzin Dmitry Date: Tue, 25 Feb 2020 14:36:12 +0300 Subject: [PATCH 07/26] update jobs --- .travis.yml | 6 ++++++ Makefile | 2 ++ 2 files changed, 8 insertions(+) diff --git a/.travis.yml b/.travis.yml index 3175978..4a087dc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,6 +19,12 @@ jobs: include: - php: 5.6 env: WP_VERSION=latest WP_MULTISITE=0 + - php: 7.0 + env: WP_VERSION=latest WP_MULTISITE=0 + - php: 7.1 + env: WP_VERSION=latest WP_MULTISITE=0 + - php: 7.2 + env: WP_VERSION=latest WP_MULTISITE=0 USE_COMPOSER=1 - stage: deploy deploy: cleanup: false diff --git a/Makefile b/Makefile index e9345c2..76b5c19 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,8 @@ FILE = $(TRAVIS_BUILD_DIR)/VERSION VERSION = `cat $(FILE)` +.PHONY: tests + all: svn_clone svn_push remove_dir svn_clone: From c8cdedce3f148c518f2ca3bb5747dcd0bc69bf2e Mon Sep 17 00:00:00 2001 From: Akolzin Dmitry Date: Tue, 25 Feb 2020 14:40:36 +0300 Subject: [PATCH 08/26] update phpunit config --- phpunit.xml.dist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 44f2477..a089447 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,6 +1,6 @@ Date: Tue, 25 Feb 2020 14:45:04 +0300 Subject: [PATCH 09/26] update bootstrap --- tests/bootstrap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index f531b62..b475d5a 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -9,7 +9,7 @@ if (!$_tests_dir) { require_once $_tests_dir . '/includes/functions.php'; function _manually_load_plugin() { - $plugin_dir = dirname(dirname(dirname(__FILE__))) . '/'; + $plugin_dir = dirname(dirname(__FILE__)) . '/'; require $plugin_dir . 'src/include/class-wc-retailcrm-orders.php'; require $plugin_dir . 'src/include/class-wc-retailcrm-customers.php'; From 7d0c1ac904730eab45ded32704793154403b4175 Mon Sep 17 00:00:00 2001 From: Akolzin Dmitry Date: Tue, 25 Feb 2020 14:49:47 +0300 Subject: [PATCH 10/26] update bootstrap --- tests/bootstrap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index b475d5a..ed438a0 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -24,7 +24,7 @@ tests_add_filter('muplugins_loaded', '_manually_load_plugin'); require '/tmp/woocommerce/tests/bootstrap.php'; -$plugin_dir = dirname(dirname(dirname(__FILE__))) . '/'; +$plugin_dir = dirname(dirname(__FILE__)) . '/'; // helpers require $plugin_dir . 'tests/helpers/class-wc-retailcrm-response-helper.php'; require $plugin_dir . 'tests/helpers/class-wc-retailcrm-test-case-helper.php'; From 2142e2a01fee7609d21c18c8c02daac17edbe0bf Mon Sep 17 00:00:00 2001 From: Akolzin Dmitry Date: Wed, 26 Feb 2020 17:23:12 +0300 Subject: [PATCH 11/26] matrix --- .travis.yml | 24 ++++++++++++++++++++---- Makefile | 2 +- tests/bin/install.sh | 3 ++- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4a087dc..46d3ced 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,13 +18,29 @@ script: make tests jobs: include: - php: 5.6 - env: WP_VERSION=latest WP_MULTISITE=0 + env: WP_VERSION=4.4 WC_VERSION=3.0.0 WP_MULTISITE=0 - php: 7.0 - env: WP_VERSION=latest WP_MULTISITE=0 + env: WP_VERSION=4.4 WC_VERSION=3.0.0 WP_MULTISITE=0 - php: 7.1 - env: WP_VERSION=latest WP_MULTISITE=0 + env: WP_VERSION=4.4 WC_VERSION=3.0.0 WP_MULTISITE=0 - php: 7.2 - env: WP_VERSION=latest WP_MULTISITE=0 USE_COMPOSER=1 + env: WP_VERSION=4.4 WC_VERSION=3.0.0 WP_MULTISITE=0 USE_COMPOSER=1 + - php: 5.6 + env: WP_VERSION=4.4 WC_VERSION=3.1.0 WP_MULTISITE=0 + - php: 7.0 + env: WP_VERSION=4.4 WC_VERSION=3.1.0 WP_MULTISITE=0 + - php: 7.1 + env: WP_VERSION=4.4 WC_VERSION=3.1.0 WP_MULTISITE=0 + - php: 7.2 + env: WP_VERSION=4.4 WC_VERSION=3.1.0 WP_MULTISITE=0 USE_COMPOSER=1 + - php: 5.6 + env: WP_VERSION=4.4 WC_VERSION=3.2.0 WP_MULTISITE=0 + - php: 7.0 + env: WP_VERSION=4.4 WC_VERSION=3.2.0 WP_MULTISITE=0 + - php: 7.1 + env: WP_VERSION=4.4 WC_VERSION=3.2.0 WP_MULTISITE=0 + - php: 7.2 + env: WP_VERSION=4.4 WC_VERSION=3.2.0 WP_MULTISITE=0 USE_COMPOSER=1 - stage: deploy deploy: cleanup: false diff --git a/Makefile b/Makefile index 76b5c19..193a0fd 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ compile_pot: msgfmt resources/pot/retailcrm-es_ES.pot -o src/languages/retailcrm-es_ES.mo install: - bash tests/bin/install.sh wc_retailcrm_test root '' localhost $(WP_VERSION) + bash tests/bin/install.sh wc_retailcrm_test root '' localhost $(WP_VERSION) $(WC_VERSION) ifeq ($(USE_COMPOSER),1) composer install endif diff --git a/tests/bin/install.sh b/tests/bin/install.sh index d3ca88c..9763093 100755 --- a/tests/bin/install.sh +++ b/tests/bin/install.sh @@ -12,6 +12,7 @@ DB_PASS=$3 DB_HOST=${4-localhost} WP_VERSION=${5-latest} SKIP_DB_CREATE=${6-false} +WC_VERSION=${7-3.9.0} WP_TESTS_DIR=${WP_TESTS_DIR-/tmp/wordpress-tests-lib} WP_CORE_DIR=${WP_CORE_DIR-/tmp/wordpress/} @@ -72,7 +73,7 @@ install_woocommerce() { cd /tmp git clone https://github.com/woocommerce/woocommerce.git cd woocommerce - git checkout master + git checkout $WC_VERSION composer install npm install cd - From 24efcdf23a2f3800fcc5cb020d90d14230086e30 Mon Sep 17 00:00:00 2001 From: Akolzin Dmitry Date: Thu, 27 Feb 2020 14:12:42 +0300 Subject: [PATCH 12/26] update jobs --- .docker/Dockerfile | 34 ++++++++++++++++++++++++++++++++++ .env-dist | 6 ++++++ .gitignore | 1 + .travis.yml | 33 ++++++++++++++++++++++++++++++++- Makefile | 11 +++++++---- docker-compose.yml | 34 ++++++++++++++++++++++++++++++++++ tests/bin/install.sh | 13 +++++++++---- 7 files changed, 123 insertions(+), 9 deletions(-) create mode 100644 .docker/Dockerfile create mode 100644 .env-dist create mode 100644 docker-compose.yml diff --git a/.docker/Dockerfile b/.docker/Dockerfile new file mode 100644 index 0000000..b8242fa --- /dev/null +++ b/.docker/Dockerfile @@ -0,0 +1,34 @@ +FROM php:7.1-fpm + +RUN apt-get update + +RUN apt-get install -y zlib1g-dev libpq-dev git libicu-dev libxml2-dev libpng-dev libjpeg-dev libmcrypt-dev libxslt-dev libfreetype6-dev \ + && docker-php-ext-configure intl \ + && docker-php-ext-install intl \ + && docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \ + && docker-php-ext-install mysqli pdo pdo_mysql \ + && docker-php-ext-install zip \ + && docker-php-ext-install xml \ + && docker-php-ext-configure gd --with-png-dir=/usr/local/ --with-jpeg-dir=/usr/local/ --with-freetype-dir=/usr/local/ \ + && docker-php-ext-install gd \ + && docker-php-ext-install mcrypt \ + && docker-php-ext-install bcmath \ + && docker-php-ext-install soap \ + && docker-php-ext-install xsl \ + && docker-php-ext-install mbstring + +RUN apt-get install -y subversion +RUN apt-get install -y wget + +RUN wget -O /usr/bin/phpunit https://phar.phpunit.de/phpunit-6.phar && chmod +x /usr/bin/phpunit +RUN curl --insecure https://getcomposer.org/composer.phar -o /usr/bin/composer && chmod +x /usr/bin/composer + +RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - +RUN apt-get install -y nodejs + +# Set timezone +RUN rm /etc/localtime +RUN ln -s /usr/share/zoneinfo/Europe/Moscow /etc/localtime +RUN "date" + +WORKDIR /code \ No newline at end of file diff --git a/.env-dist b/.env-dist new file mode 100644 index 0000000..17a33c9 --- /dev/null +++ b/.env-dist @@ -0,0 +1,6 @@ +DB_NAME=wc_retailcrm_test +DB_USER=wc_retailcrm +DB_PASS=wc_retailcrm +DB_HOST=mysql +WP_VERSION=4.4 +WC_VERSION=3.0.0 diff --git a/.gitignore b/.gitignore index 5b40963..6cf54b2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /nbproject/ /vendor/ .idea/ +.env diff --git a/.travis.yml b/.travis.yml index 46d3ced..9eb229c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,10 +13,41 @@ before_script: - nvm install 10 - make install -script: make tests +env: + global: + - DB_NAME=wc_retailcrm_test + - DB_USER=root + - DB_PASS='' + - DB_HOST=localhost + +script: make test jobs: include: + - php: 5.6 + env: WP_VERSION=latest WC_VERSION=3.8.0 WP_MULTISITE=0 + - php: 7.0 + env: WP_VERSION=latest WC_VERSION=3.8.0 WP_MULTISITE=0 + - php: 7.1 + env: WP_VERSION=latest WC_VERSION=3.8.0 WP_MULTISITE=0 + - php: 7.2 + env: WP_VERSION=latest WC_VERSION=3.8.0 WP_MULTISITE=0 USE_COMPOSER=1 + - php: 5.6 + env: WP_VERSION=latest WC_VERSION=3.9.0 WP_MULTISITE=0 + - php: 7.0 + env: WP_VERSION=latest WC_VERSION=3.9.0 WP_MULTISITE=0 + - php: 7.1 + env: WP_VERSION=latest WC_VERSION=3.9.0 WP_MULTISITE=0 + - php: 7.2 + env: WP_VERSION=latest WC_VERSION=3.9.0 WP_MULTISITE=0 USE_COMPOSER=1 + - php: 5.6 + env: WP_VERSION=4.4 WC_VERSION=3.2.0 WP_MULTISITE=0 + - php: 7.0 + env: WP_VERSION=4.4 WC_VERSION=3.2.0 WP_MULTISITE=0 + - php: 7.1 + env: WP_VERSION=4.4 WC_VERSION=3.2.0 WP_MULTISITE=0 + - php: 7.2 + env: WP_VERSION=4.4 WC_VERSION=3.2.0 WP_MULTISITE=0 USE_COMPOSER=1 - php: 5.6 env: WP_VERSION=4.4 WC_VERSION=3.0.0 WP_MULTISITE=0 - php: 7.0 diff --git a/Makefile b/Makefile index 193a0fd..b231783 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ FILE = $(TRAVIS_BUILD_DIR)/VERSION VERSION = `cat $(FILE)` -.PHONY: tests +.PHONY: test all: svn_clone svn_push remove_dir @@ -28,14 +28,17 @@ compile_pot: msgfmt resources/pot/retailcrm-es_ES.pot -o src/languages/retailcrm-es_ES.mo install: - bash tests/bin/install.sh wc_retailcrm_test root '' localhost $(WP_VERSION) $(WC_VERSION) + bash tests/bin/install.sh $(DB_NAME) $(DB_USER) $(DB_PASS) $(DB_HOST) $(WP_VERSION) $(WC_VERSION) $(SKIP_DB_CREATE) ifeq ($(USE_COMPOSER),1) composer install endif -tests: +test: ifeq ($(USE_COMPOSER),1) vendor/phpunit/phpunit/phpunit -c phpunit.xml.dist else phpunit -c phpunit.xml.dist -endif \ No newline at end of file +endif + +local_test: install + phpunit -c phpunit.xml.dist diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..75b9f70 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,34 @@ +version: '3' +services: + app: + build: + context: ./.docker + volumes: + - ./:/code + links: + - "mysql" + #user: ${UID:-1000}:${GID:-1000} + depends_on: + - mysql + entrypoint: make local_test + env_file: + - ./.env + environment: + - DB_NAME=${DB_NAME} + - DB_USER=${DB_USER} + - DB_PASS=${DB_PASS} + - DB_HOST=${DB_HOST} + - WP_VERSION=${WP_VERSION} + - WC_VERSION=${WC_VERSION} + - SKIP_DB_CREATE=true + mysql: + image: mysql:5.7 + env_file: + - ./.env + environment: + - MYSQL_DATABASE=${DB_NAME} + - MYSQL_USER=${DB_USER} + - MYSQL_PASSWORD=${DB_PASS} + - MYSQL_ROOT_PASSWORD=root + ports: + - "3306:3306" diff --git a/tests/bin/install.sh b/tests/bin/install.sh index 9763093..264afce 100755 --- a/tests/bin/install.sh +++ b/tests/bin/install.sh @@ -11,8 +11,8 @@ DB_USER=$2 DB_PASS=$3 DB_HOST=${4-localhost} WP_VERSION=${5-latest} -SKIP_DB_CREATE=${6-false} -WC_VERSION=${7-3.9.0} +WC_VERSION=${6-3.9.0} +SKIP_DB_CREATE=${7-false} WP_TESTS_DIR=${WP_TESTS_DIR-/tmp/wordpress-tests-lib} WP_CORE_DIR=${WP_CORE_DIR-/tmp/wordpress/} @@ -70,6 +70,8 @@ install_wp() { } install_woocommerce() { + if [[ ! -d "/tmp/woocommerce" ]] + then cd /tmp git clone https://github.com/woocommerce/woocommerce.git cd woocommerce @@ -77,6 +79,7 @@ install_woocommerce() { composer install npm install cd - + fi } install_test_suite() { @@ -130,8 +133,10 @@ install_db() { fi fi - # create database - mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA + if [ ${DB_HOST} == "localhost" ]; then + # create database + mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA --host=$DB_HOST + fi } install_wp From 56b1eb81d2e7b444b70c2a05756122ae1c37d5a1 Mon Sep 17 00:00:00 2001 From: Akolzin Dmitry Date: Fri, 28 Feb 2020 16:32:18 +0300 Subject: [PATCH 13/26] update transfer DB_PASS --- Makefile | 2 +- tests/bin/install.sh | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index b231783..fb8f0c9 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ compile_pot: msgfmt resources/pot/retailcrm-es_ES.pot -o src/languages/retailcrm-es_ES.mo install: - bash tests/bin/install.sh $(DB_NAME) $(DB_USER) $(DB_PASS) $(DB_HOST) $(WP_VERSION) $(WC_VERSION) $(SKIP_DB_CREATE) + bash tests/bin/install.sh $(DB_NAME) $(DB_USER) $(DB_HOST) $(WP_VERSION) $(WC_VERSION) $(DB_PASS) $(SKIP_DB_CREATE) ifeq ($(USE_COMPOSER),1) composer install endif diff --git a/tests/bin/install.sh b/tests/bin/install.sh index 264afce..f3a3c60 100755 --- a/tests/bin/install.sh +++ b/tests/bin/install.sh @@ -8,10 +8,10 @@ fi DB_NAME=$1 DB_USER=$2 -DB_PASS=$3 -DB_HOST=${4-localhost} -WP_VERSION=${5-latest} -WC_VERSION=${6-3.9.0} +DB_HOST=${3-localhost} +WP_VERSION=${4-latest} +WC_VERSION=${5-3.9.0} +DB_PASS=${6-''} SKIP_DB_CREATE=${7-false} WP_TESTS_DIR=${WP_TESTS_DIR-/tmp/wordpress-tests-lib} From 2d75f50a0830899264068aa4062994330c8aa17d Mon Sep 17 00:00:00 2001 From: Akolzin Dmitry Date: Mon, 2 Mar 2020 13:54:34 +0300 Subject: [PATCH 14/26] update matrix --- .travis.yml | 188 +++++++++++++++++++++++++++++++++++-------- tests/bin/install.sh | 19 ++++- 2 files changed, 170 insertions(+), 37 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9eb229c..0703049 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,54 +24,174 @@ script: make test jobs: include: + - php: 5.4 + env: WP_VERSION=4.4 WC_VERSION=3.0.0 WP_MULTISITE=0 - php: 5.6 - env: WP_VERSION=latest WC_VERSION=3.8.0 WP_MULTISITE=0 + env: WP_VERSION=4.4 WC_VERSION=3.0.0 WP_MULTISITE=0 + - php: 5.4 + env: WP_VERSION=4.4 WC_VERSION=3.1.0 WP_MULTISITE=0 + - php: 5.6 + env: WP_VERSION=4.4 WC_VERSION=3.1.0 WP_MULTISITE=0 + - php: 5.4 + env: WP_VERSION=4.4 WC_VERSION=3.2.0 WP_MULTISITE=0 + - php: 5.6 + env: WP_VERSION=4.4 WC_VERSION=3.2.0 WP_MULTISITE=0 + + - php: 5.4 + env: WP_VERSION=4.5 WC_VERSION=3.0.0 WP_MULTISITE=0 + - php: 5.6 + env: WP_VERSION=4.5 WC_VERSION=3.0.0 WP_MULTISITE=0 + - php: 5.4 + env: WP_VERSION=4.5 WC_VERSION=3.1.0 WP_MULTISITE=0 + - php: 5.6 + env: WP_VERSION=4.5 WC_VERSION=3.1.0 WP_MULTISITE=0 + - php: 5.4 + env: WP_VERSION=4.5 WC_VERSION=3.2.0 WP_MULTISITE=0 + - php: 5.6 + env: WP_VERSION=4.5 WC_VERSION=3.2.0 WP_MULTISITE=0 + + - php: 5.4 + env: WP_VERSION=4.6 WC_VERSION=3.0.0 WP_MULTISITE=0 + - php: 5.6 + env: WP_VERSION=4.6 WC_VERSION=3.0.0 WP_MULTISITE=0 + - php: 5.4 + env: WP_VERSION=4.6 WC_VERSION=3.1.0 WP_MULTISITE=0 + - php: 5.6 + env: WP_VERSION=4.6 WC_VERSION=3.1.0 WP_MULTISITE=0 + - php: 5.4 + env: WP_VERSION=4.6 WC_VERSION=3.2.0 WP_MULTISITE=0 + - php: 5.6 + env: WP_VERSION=4.6 WC_VERSION=3.2.0 WP_MULTISITE=0 + + - php: 5.4 + env: WP_VERSION=4.7 WC_VERSION=3.0.0 WP_MULTISITE=0 + - php: 5.6 + env: WP_VERSION=4.7 WC_VERSION=3.0.0 WP_MULTISITE=0 + - php: 5.4 + env: WP_VERSION=4.7 WC_VERSION=3.1.0 WP_MULTISITE=0 + - php: 5.6 + env: WP_VERSION=4.7 WC_VERSION=3.1.0 WP_MULTISITE=0 + - php: 5.4 + env: WP_VERSION=4.7 WC_VERSION=3.2.0 WP_MULTISITE=0 + - php: 5.6 + env: WP_VERSION=4.7 WC_VERSION=3.2.0 WP_MULTISITE=0 + + - php: 5.6 + env: WP_VERSION=4.8 WC_VERSION=3.3.0 WP_MULTISITE=0 - php: 7.0 - env: WP_VERSION=latest WC_VERSION=3.8.0 WP_MULTISITE=0 + env: WP_VERSION=4.8 WC_VERSION=3.3.0 WP_MULTISITE=0 - php: 7.1 - env: WP_VERSION=latest WC_VERSION=3.8.0 WP_MULTISITE=0 + env: WP_VERSION=4.8 WC_VERSION=3.3.0 WP_MULTISITE=0 - php: 7.2 - env: WP_VERSION=latest WC_VERSION=3.8.0 WP_MULTISITE=0 USE_COMPOSER=1 + env: WP_VERSION=4.8 WC_VERSION=3.3.0 WP_MULTISITE=0 USE_COMPOSER=1 + - php: 5.6 - env: WP_VERSION=latest WC_VERSION=3.9.0 WP_MULTISITE=0 + env: WP_VERSION=4.8 WC_VERSION=3.4.0 WP_MULTISITE=0 + - php: 7.0 + env: WP_VERSION=4.8 WC_VERSION=3.4.0 WP_MULTISITE=0 + - php: 7.1 + env: WP_VERSION=4.8 WC_VERSION=3.4.0 WP_MULTISITE=0 + - php: 7.2 + env: WP_VERSION=4.8 WC_VERSION=3.4.0 WP_MULTISITE=0 USE_COMPOSER=1 + + - php: 5.6 + env: WP_VERSION=4.8 WC_VERSION=3.5.0 WP_MULTISITE=0 + - php: 7.0 + env: WP_VERSION=4.8 WC_VERSION=3.5.0 WP_MULTISITE=0 + - php: 7.1 + env: WP_VERSION=4.8 WC_VERSION=3.5.0 WP_MULTISITE=0 + - php: 7.2 + env: WP_VERSION=4.8 WC_VERSION=3.5.0 WP_MULTISITE=0 USE_COMPOSER=1 + + - php: 5.6 + env: WP_VERSION=4.9 WC_VERSION=3.3.0 WP_MULTISITE=0 + - php: 7.0 + env: WP_VERSION=4.9 WC_VERSION=3.3.0 WP_MULTISITE=0 + - php: 7.1 + env: WP_VERSION=4.9 WC_VERSION=3.3.0 WP_MULTISITE=0 + - php: 7.2 + env: WP_VERSION=4.9 WC_VERSION=3.3.0 WP_MULTISITE=0 USE_COMPOSER=1 + + - php: 5.6 + env: WP_VERSION=4.9 WC_VERSION=3.4.0 WP_MULTISITE=0 + - php: 7.0 + env: WP_VERSION=4.9 WC_VERSION=3.4.0 WP_MULTISITE=0 + - php: 7.1 + env: WP_VERSION=4.9 WC_VERSION=3.4.0 WP_MULTISITE=0 + - php: 7.2 + env: WP_VERSION=4.9 WC_VERSION=3.4.0 WP_MULTISITE=0 USE_COMPOSER=1 + + - php: 5.6 + env: WP_VERSION=4.9 WC_VERSION=3.5.0 WP_MULTISITE=0 + - php: 7.0 + env: WP_VERSION=4.9 WC_VERSION=3.5.0 WP_MULTISITE=0 + - php: 7.1 + env: WP_VERSION=4.9 WC_VERSION=3.5.0 WP_MULTISITE=0 + - php: 7.2 + env: WP_VERSION=4.9 WC_VERSION=3.5.0 WP_MULTISITE=0 USE_COMPOSER=1 + + - php: 5.6 + env: WP_VERSION=5.0 WC_VERSION=3.6.0 WP_MULTISITE=0 + - php: 7.0 + env: WP_VERSION=5.0 WC_VERSION=3.6.0 WP_MULTISITE=0 + - php: 7.1 + env: WP_VERSION=5.0 WC_VERSION=3.6.0 WP_MULTISITE=0 + - php: 7.2 + env: WP_VERSION=5.0 WC_VERSION=3.6.0 WP_MULTISITE=0 USE_COMPOSER=1 + + - php: 5.6 + env: WP_VERSION=5.1 WC_VERSION=3.6.0 WP_MULTISITE=0 + - php: 7.0 + env: WP_VERSION=5.1 WC_VERSION=3.6.0 WP_MULTISITE=0 + - php: 7.1 + env: WP_VERSION=5.1 WC_VERSION=3.6.0 WP_MULTISITE=0 + - php: 7.2 + env: WP_VERSION=5.1 WC_VERSION=3.6.0 WP_MULTISITE=0 USE_COMPOSER=1 + + - php: 5.6 + env: WP_VERSION=5.2 WC_VERSION=3.6.0 WP_MULTISITE=0 + - php: 7.0 + env: WP_VERSION=5.2 WC_VERSION=3.6.0 WP_MULTISITE=0 + - php: 7.1 + env: WP_VERSION=5.2 WC_VERSION=3.6.0 WP_MULTISITE=0 + - php: 7.2 + env: WP_VERSION=5.2 WC_VERSION=3.6.0 WP_MULTISITE=0 USE_COMPOSER=1 + + - php: 7.0 + env: WP_VERSION=5.1 WC_VERSION=3.7.0 WP_MULTISITE=0 + - php: 7.1 + env: WP_VERSION=5.1 WC_VERSION=3.7.0 WP_MULTISITE=0 + - php: 7.2 + env: WP_VERSION=5.1 WC_VERSION=3.7.0 WP_MULTISITE=0 USE_COMPOSER=1 + + - php: 7.0 + env: WP_VERSION=5.2 WC_VERSION=3.7.0 WP_MULTISITE=0 + - php: 7.1 + env: WP_VERSION=5.2 WC_VERSION=3.7.0 WP_MULTISITE=0 + - php: 7.2 + env: WP_VERSION=5.2 WC_VERSION=3.7.0 WP_MULTISITE=0 USE_COMPOSER=1 + + - php: 7.0 + env: WP_VERSION=5.3 WC_VERSION=3.8.0 WP_MULTISITE=0 + - php: 7.1 + env: WP_VERSION=5.3 WC_VERSION=3.8.0 WP_MULTISITE=0 + - php: 7.2 + env: WP_VERSION=5.3 WC_VERSION=3.8.0 WP_MULTISITE=0 USE_COMPOSER=1 + - php: 7.0 env: WP_VERSION=latest WC_VERSION=3.9.0 WP_MULTISITE=0 - php: 7.1 env: WP_VERSION=latest WC_VERSION=3.9.0 WP_MULTISITE=0 - php: 7.2 env: WP_VERSION=latest WC_VERSION=3.9.0 WP_MULTISITE=0 USE_COMPOSER=1 - - php: 5.6 - env: WP_VERSION=4.4 WC_VERSION=3.2.0 WP_MULTISITE=0 + - php: 7.0 - env: WP_VERSION=4.4 WC_VERSION=3.2.0 WP_MULTISITE=0 + env: WP_VERSION=latest WC_VERSION=latest WP_MULTISITE=0 - php: 7.1 - env: WP_VERSION=4.4 WC_VERSION=3.2.0 WP_MULTISITE=0 + env: WP_VERSION=latest WC_VERSION=latest WP_MULTISITE=0 - php: 7.2 - env: WP_VERSION=4.4 WC_VERSION=3.2.0 WP_MULTISITE=0 USE_COMPOSER=1 - - php: 5.6 - env: WP_VERSION=4.4 WC_VERSION=3.0.0 WP_MULTISITE=0 - - php: 7.0 - env: WP_VERSION=4.4 WC_VERSION=3.0.0 WP_MULTISITE=0 - - php: 7.1 - env: WP_VERSION=4.4 WC_VERSION=3.0.0 WP_MULTISITE=0 - - php: 7.2 - env: WP_VERSION=4.4 WC_VERSION=3.0.0 WP_MULTISITE=0 USE_COMPOSER=1 - - php: 5.6 - env: WP_VERSION=4.4 WC_VERSION=3.1.0 WP_MULTISITE=0 - - php: 7.0 - env: WP_VERSION=4.4 WC_VERSION=3.1.0 WP_MULTISITE=0 - - php: 7.1 - env: WP_VERSION=4.4 WC_VERSION=3.1.0 WP_MULTISITE=0 - - php: 7.2 - env: WP_VERSION=4.4 WC_VERSION=3.1.0 WP_MULTISITE=0 USE_COMPOSER=1 - - php: 5.6 - env: WP_VERSION=4.4 WC_VERSION=3.2.0 WP_MULTISITE=0 - - php: 7.0 - env: WP_VERSION=4.4 WC_VERSION=3.2.0 WP_MULTISITE=0 - - php: 7.1 - env: WP_VERSION=4.4 WC_VERSION=3.2.0 WP_MULTISITE=0 - - php: 7.2 - env: WP_VERSION=4.4 WC_VERSION=3.2.0 WP_MULTISITE=0 USE_COMPOSER=1 + env: WP_VERSION=latest WC_VERSION=latest WP_MULTISITE=0 USE_COMPOSER=1 + - stage: deploy deploy: cleanup: false diff --git a/tests/bin/install.sh b/tests/bin/install.sh index f3a3c60..32ee52c 100755 --- a/tests/bin/install.sh +++ b/tests/bin/install.sh @@ -75,9 +75,22 @@ install_woocommerce() { cd /tmp git clone https://github.com/woocommerce/woocommerce.git cd woocommerce - git checkout $WC_VERSION - composer install - npm install + + if [[ $WC_VERSION -ne 'latest' ]]; then + git checkout $WC_VERSION + + version=$(echo $WC_VERSION | tr ".") + if [[ ${version[0]} -ge 3 && ${version[1]} -ge 7 ]]; then + composer install + npm install + fi + fi + + if [[ $WC_VERSION -eq 'latest' ]]; then + composer install + npm install + fi + cd - fi } From 31865ae3ea8ddbe6c37569aff75990b119504c29 Mon Sep 17 00:00:00 2001 From: Akolzin Dmitry Date: Mon, 2 Mar 2020 14:03:56 +0300 Subject: [PATCH 15/26] fix bash script --- tests/bin/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/bin/install.sh b/tests/bin/install.sh index 32ee52c..2c2152b 100755 --- a/tests/bin/install.sh +++ b/tests/bin/install.sh @@ -79,7 +79,7 @@ install_woocommerce() { if [[ $WC_VERSION -ne 'latest' ]]; then git checkout $WC_VERSION - version=$(echo $WC_VERSION | tr ".") + version=($(echo $WC_VERSION | tr "." "\n")) if [[ ${version[0]} -ge 3 && ${version[1]} -ge 7 ]]; then composer install npm install From a0613d83e55272a9cd63f4e2bd495df603109b42 Mon Sep 17 00:00:00 2001 From: Akolzin Dmitry Date: Mon, 2 Mar 2020 14:13:27 +0300 Subject: [PATCH 16/26] fix bash script --- tests/bin/install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/bin/install.sh b/tests/bin/install.sh index 2c2152b..3c65926 100755 --- a/tests/bin/install.sh +++ b/tests/bin/install.sh @@ -76,7 +76,7 @@ install_woocommerce() { git clone https://github.com/woocommerce/woocommerce.git cd woocommerce - if [[ $WC_VERSION -ne 'latest' ]]; then + if [[ ! $WC_VERSION == 'latest' ]]; then git checkout $WC_VERSION version=($(echo $WC_VERSION | tr "." "\n")) @@ -86,7 +86,7 @@ install_woocommerce() { fi fi - if [[ $WC_VERSION -eq 'latest' ]]; then + if [[ ! $WC_VERSION == 'latest' ]]; then composer install npm install fi From d3448908e72416cd3a25ee2e9c6a88d324dee527 Mon Sep 17 00:00:00 2001 From: Akolzin Dmitry Date: Mon, 2 Mar 2020 14:20:45 +0300 Subject: [PATCH 17/26] fix bash script --- tests/bin/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/bin/install.sh b/tests/bin/install.sh index 3c65926..ee83850 100755 --- a/tests/bin/install.sh +++ b/tests/bin/install.sh @@ -86,7 +86,7 @@ install_woocommerce() { fi fi - if [[ ! $WC_VERSION == 'latest' ]]; then + if [[ $WC_VERSION == 'latest' ]]; then composer install npm install fi From 68343b7e49981a8bedcbed1c810a52bdec080a06 Mon Sep 17 00:00:00 2001 From: Akolzin Dmitry Date: Mon, 2 Mar 2020 18:02:40 +0300 Subject: [PATCH 18/26] update history --- .docker/Dockerfile | 4 ++-- .travis.yml | 1 + composer.json | 2 ++ phpunit.xml.dist | 10 +++++++--- src/include/class-wc-retailcrm-history.php | 3 ++- tests/test-wc-retailcrm-orders.php | 13 +++++++++++-- 6 files changed, 25 insertions(+), 8 deletions(-) diff --git a/.docker/Dockerfile b/.docker/Dockerfile index b8242fa..37bfccf 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -1,4 +1,4 @@ -FROM php:7.1-fpm +FROM php:5.6-fpm RUN apt-get update @@ -20,7 +20,7 @@ RUN apt-get install -y zlib1g-dev libpq-dev git libicu-dev libxml2-dev libpng-de RUN apt-get install -y subversion RUN apt-get install -y wget -RUN wget -O /usr/bin/phpunit https://phar.phpunit.de/phpunit-6.phar && chmod +x /usr/bin/phpunit +RUN wget -O /usr/bin/phpunit https://phar.phpunit.de/phpunit-5.phar && chmod +x /usr/bin/phpunit RUN curl --insecure https://getcomposer.org/composer.phar -o /usr/bin/composer && chmod +x /usr/bin/composer RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - diff --git a/.travis.yml b/.travis.yml index 0703049..d1613c6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -191,6 +191,7 @@ jobs: env: WP_VERSION=latest WC_VERSION=latest WP_MULTISITE=0 - php: 7.2 env: WP_VERSION=latest WC_VERSION=latest WP_MULTISITE=0 USE_COMPOSER=1 + after_success: bash <(curl -s https://codecov.io/bash) - stage: deploy deploy: diff --git a/composer.json b/composer.json index 12e462c..7bffffe 100644 --- a/composer.json +++ b/composer.json @@ -11,6 +11,8 @@ "minimum-stability": "dev", "require": {}, "require-dev": { + "ext-json": "*", + "ext-mbstring": "*", "phpunit/phpunit": "6.*" } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index a089447..6fb729f 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -18,12 +18,16 @@ - src/include + src src/include/api - src/retailcrm.php - src/uninstall.php + src/config + src/languages + src/readme.txt + + + \ No newline at end of file diff --git a/src/include/class-wc-retailcrm-history.php b/src/include/class-wc-retailcrm-history.php index b38fa86..17612d7 100644 --- a/src/include/class-wc-retailcrm-history.php +++ b/src/include/class-wc-retailcrm-history.php @@ -353,7 +353,8 @@ if ( ! class_exists( 'WC_Retailcrm_History' ) ) : $arItemsNew[$order_item_id] = $order_item_id; } - $result = end(array_diff($arItemsNew, $arItemsOld)); + $diff = array_diff($arItemsNew, $arItemsOld); + $result = end($diff); $order['items'][$key]['woocomerceId'] = $result; } else { foreach ($wc_order->get_items() as $order_item_id => $order_item) { diff --git a/tests/test-wc-retailcrm-orders.php b/tests/test-wc-retailcrm-orders.php index b7df534..bda8a84 100644 --- a/tests/test-wc-retailcrm-orders.php +++ b/tests/test-wc-retailcrm-orders.php @@ -106,7 +106,11 @@ class WC_Retailcrm_Orders_Test extends WC_Retailcrm_Test_Case_Helper $this->assertEquals('Sormani', $order_send['lastName']); $this->assertEquals('admin@example.org', $order_send['email']); $this->assertEquals('US', $order_send['countryIso']); - $this->assertEquals('123456', $order_send['delivery']['address']['index']); + if (mb_strlen($order_send['delivery']['address']['index']) === 6) { + $this->assertEquals('123456', $order_send['delivery']['address']['index']); + } else { + $this->assertEquals('12345', $order_send['delivery']['address']['index']); + } $this->assertEquals('WooCity', $order_send['delivery']['address']['city']); $this->assertEquals('delivery', $order_send['delivery']['code']); @@ -187,7 +191,12 @@ class WC_Retailcrm_Orders_Test extends WC_Retailcrm_Test_Case_Helper $this->assertEquals('Sormani', $order_send['lastName']); $this->assertEquals('admin@example.org', $order_send['email']); $this->assertEquals('US', $order_send['countryIso']); - $this->assertEquals('123456', $order_send['delivery']['address']['index']); + if (mb_strlen($order_send['delivery']['address']['index']) === 6) { + $this->assertEquals('123456', $order_send['delivery']['address']['index']); + } else { + $this->assertEquals('12345', $order_send['delivery']['address']['index']); + } + $this->assertEquals('WooCity', $order_send['delivery']['address']['city']); $this->assertEquals('delivery', $order_send['delivery']['code']); From baa1f3d5811c3b1218cd48e5bf18b0c2d592fe63 Mon Sep 17 00:00:00 2001 From: Akolzin Dmitry Date: Tue, 3 Mar 2020 10:20:58 +0300 Subject: [PATCH 19/26] add php5.3 --- .docker/Dockerfile | 2 +- .travis.yml | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.docker/Dockerfile b/.docker/Dockerfile index 37bfccf..ec98202 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -1,4 +1,4 @@ -FROM php:5.6-fpm +FROM php:7.1-fpm RUN apt-get update diff --git a/.travis.yml b/.travis.yml index d1613c6..990045d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,6 +24,9 @@ script: make test jobs: include: + - php: 5.3 + dist: precise + env: WP_VERSION=4.4 WC_VERSION=3.0.0 WP_MULTISITE=0 - php: 5.4 env: WP_VERSION=4.4 WC_VERSION=3.0.0 WP_MULTISITE=0 - php: 5.6 From 92a5673614eac430f5d49d191108c17147bdaf82 Mon Sep 17 00:00:00 2001 From: Akolzin Dmitry Date: Tue, 3 Mar 2020 10:24:43 +0300 Subject: [PATCH 20/26] fix for php5.3 --- src/include/class-wc-retailcrm-history.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/include/class-wc-retailcrm-history.php b/src/include/class-wc-retailcrm-history.php index 17612d7..ff732ea 100644 --- a/src/include/class-wc-retailcrm-history.php +++ b/src/include/class-wc-retailcrm-history.php @@ -358,9 +358,6 @@ if ( ! class_exists( 'WC_Retailcrm_History' ) ) : $order['items'][$key]['woocomerceId'] = $result; } else { foreach ($wc_order->get_items() as $order_item_id => $order_item) { - - - if ($order_item['variation_id'] != 0 ) { $offer_id = $order_item['variation_id']; } else { @@ -671,7 +668,7 @@ if ( ! class_exists( 'WC_Retailcrm_History' ) ) : */ protected function editOrder($settings, $wc_order, $order, $event = 'create') { - $order_items = []; + $order_items = array(); if ($event == 'update') { $result = $this->retailcrm->ordersGet($order['externalId']); if ($result->isSuccessful()) { @@ -703,10 +700,10 @@ if ( ! class_exists( 'WC_Retailcrm_History' ) ) : } if (!empty($order_items)) { - $orderEdit = [ + $orderEdit = array( 'id' => $order['id'], 'items' => $order_items, - ]; + ); $this->retailcrm->ordersEdit($orderEdit, 'id'); } From f9b872e6281c4142dc802b2c1c460a2b94fbc7b3 Mon Sep 17 00:00:00 2001 From: Akolzin Dmitry Date: Tue, 3 Mar 2020 11:30:13 +0300 Subject: [PATCH 21/26] travis php7.3 --- .docker/Dockerfile | 2 +- .travis.yml | 41 +++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 2 +- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/.docker/Dockerfile b/.docker/Dockerfile index ec98202..cb967eb 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -20,7 +20,7 @@ RUN apt-get install -y zlib1g-dev libpq-dev git libicu-dev libxml2-dev libpng-de RUN apt-get install -y subversion RUN apt-get install -y wget -RUN wget -O /usr/bin/phpunit https://phar.phpunit.de/phpunit-5.phar && chmod +x /usr/bin/phpunit +RUN wget -O /usr/bin/phpunit https://phar.phpunit.de/phpunit-7.phar && chmod +x /usr/bin/phpunit RUN curl --insecure https://getcomposer.org/composer.phar -o /usr/bin/composer && chmod +x /usr/bin/composer RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - diff --git a/.travis.yml b/.travis.yml index 990045d..fb3fa8f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,54 +31,90 @@ jobs: env: WP_VERSION=4.4 WC_VERSION=3.0.0 WP_MULTISITE=0 - php: 5.6 env: WP_VERSION=4.4 WC_VERSION=3.0.0 WP_MULTISITE=0 + - php: 5.3 + dist: precise + env: WP_VERSION=4.4 WC_VERSION=3.1.0 WP_MULTISITE=0 - php: 5.4 env: WP_VERSION=4.4 WC_VERSION=3.1.0 WP_MULTISITE=0 - php: 5.6 env: WP_VERSION=4.4 WC_VERSION=3.1.0 WP_MULTISITE=0 + - php: 5.3 + dist: precise + env: WP_VERSION=4.4 WC_VERSION=3.2.0 WP_MULTISITE=0 - php: 5.4 env: WP_VERSION=4.4 WC_VERSION=3.2.0 WP_MULTISITE=0 - php: 5.6 env: WP_VERSION=4.4 WC_VERSION=3.2.0 WP_MULTISITE=0 + - php: 5.3 + dist: precise + env: WP_VERSION=4.5 WC_VERSION=3.0.0 WP_MULTISITE=0 - php: 5.4 env: WP_VERSION=4.5 WC_VERSION=3.0.0 WP_MULTISITE=0 - php: 5.6 env: WP_VERSION=4.5 WC_VERSION=3.0.0 WP_MULTISITE=0 + - php: 5.3 + dist: precise + env: WP_VERSION=4.5 WC_VERSION=3.1.0 WP_MULTISITE=0 - php: 5.4 env: WP_VERSION=4.5 WC_VERSION=3.1.0 WP_MULTISITE=0 - php: 5.6 env: WP_VERSION=4.5 WC_VERSION=3.1.0 WP_MULTISITE=0 + - php: 5.3 + dist: precise + env: WP_VERSION=4.5 WC_VERSION=3.2.0 WP_MULTISITE=0 - php: 5.4 env: WP_VERSION=4.5 WC_VERSION=3.2.0 WP_MULTISITE=0 - php: 5.6 env: WP_VERSION=4.5 WC_VERSION=3.2.0 WP_MULTISITE=0 + - php: 5.3 + dist: precise + env: WP_VERSION=4.6 WC_VERSION=3.0.0 WP_MULTISITE=0 - php: 5.4 env: WP_VERSION=4.6 WC_VERSION=3.0.0 WP_MULTISITE=0 - php: 5.6 env: WP_VERSION=4.6 WC_VERSION=3.0.0 WP_MULTISITE=0 + - php: 5.3 + dist: precise + env: WP_VERSION=4.6 WC_VERSION=3.1.0 WP_MULTISITE=0 - php: 5.4 env: WP_VERSION=4.6 WC_VERSION=3.1.0 WP_MULTISITE=0 - php: 5.6 env: WP_VERSION=4.6 WC_VERSION=3.1.0 WP_MULTISITE=0 + - php: 5.3 + dist: precise + env: WP_VERSION=4.6 WC_VERSION=3.2.0 WP_MULTISITE=0 - php: 5.4 env: WP_VERSION=4.6 WC_VERSION=3.2.0 WP_MULTISITE=0 - php: 5.6 env: WP_VERSION=4.6 WC_VERSION=3.2.0 WP_MULTISITE=0 + - php: 5.3 + dist: precise + env: WP_VERSION=4.7 WC_VERSION=3.0.0 WP_MULTISITE=0 - php: 5.4 env: WP_VERSION=4.7 WC_VERSION=3.0.0 WP_MULTISITE=0 - php: 5.6 env: WP_VERSION=4.7 WC_VERSION=3.0.0 WP_MULTISITE=0 + - php: 5.3 + dist: precise + env: WP_VERSION=4.7 WC_VERSION=3.1.0 WP_MULTISITE=0 - php: 5.4 env: WP_VERSION=4.7 WC_VERSION=3.1.0 WP_MULTISITE=0 - php: 5.6 env: WP_VERSION=4.7 WC_VERSION=3.1.0 WP_MULTISITE=0 + - php: 5.3 + dist: precise + env: WP_VERSION=4.7 WC_VERSION=3.2.0 WP_MULTISITE=0 - php: 5.4 env: WP_VERSION=4.7 WC_VERSION=3.2.0 WP_MULTISITE=0 - php: 5.6 env: WP_VERSION=4.7 WC_VERSION=3.2.0 WP_MULTISITE=0 + - php: 5.3 + dist: precise + env: WP_VERSION=4.8 WC_VERSION=3.3.0 WP_MULTISITE=0 - php: 5.6 env: WP_VERSION=4.8 WC_VERSION=3.3.0 WP_MULTISITE=0 - php: 7.0 @@ -88,6 +124,9 @@ jobs: - php: 7.2 env: WP_VERSION=4.8 WC_VERSION=3.3.0 WP_MULTISITE=0 USE_COMPOSER=1 + - php: 5.3 + dist: precise + env: WP_VERSION=4.8 WC_VERSION=3.4.0 WP_MULTISITE=0 - php: 5.6 env: WP_VERSION=4.8 WC_VERSION=3.4.0 WP_MULTISITE=0 - php: 7.0 @@ -194,6 +233,8 @@ jobs: env: WP_VERSION=latest WC_VERSION=latest WP_MULTISITE=0 - php: 7.2 env: WP_VERSION=latest WC_VERSION=latest WP_MULTISITE=0 USE_COMPOSER=1 + - php: 7.3 + env: WP_VERSION=latest WC_VERSION=latest WP_MULTISITE=0 after_success: bash <(curl -s https://codecov.io/bash) - stage: deploy diff --git a/docker-compose.yml b/docker-compose.yml index 75b9f70..48ed647 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,7 +7,7 @@ services: - ./:/code links: - "mysql" - #user: ${UID:-1000}:${GID:-1000} + user: ${UID:-1000}:${GID:-1000} depends_on: - mysql entrypoint: make local_test From 33afc77c094110cafc665ed86174e81e245d9890 Mon Sep 17 00:00:00 2001 From: Akolzin Dmitry Date: Tue, 3 Mar 2020 12:33:05 +0300 Subject: [PATCH 22/26] travis php7.3 --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index fb3fa8f..1f5c3b8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,6 +24,9 @@ script: make test jobs: include: + - php: 7.3 + env: WP_VERSION=latest WC_VERSION=latest WP_MULTISITE=0 USE_COMPOSER=1 + after_success: bash <(curl -s https://codecov.io/bash) - php: 5.3 dist: precise env: WP_VERSION=4.4 WC_VERSION=3.0.0 WP_MULTISITE=0 @@ -233,9 +236,6 @@ jobs: env: WP_VERSION=latest WC_VERSION=latest WP_MULTISITE=0 - php: 7.2 env: WP_VERSION=latest WC_VERSION=latest WP_MULTISITE=0 USE_COMPOSER=1 - - php: 7.3 - env: WP_VERSION=latest WC_VERSION=latest WP_MULTISITE=0 - after_success: bash <(curl -s https://codecov.io/bash) - stage: deploy deploy: From 19d1f1b179585c1b30537f13f8e2c14af38d5ee5 Mon Sep 17 00:00:00 2001 From: Akolzin Dmitry Date: Tue, 3 Mar 2020 13:51:28 +0300 Subject: [PATCH 23/26] travis php7.3 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1f5c3b8..fa9f318 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,7 +25,7 @@ script: make test jobs: include: - php: 7.3 - env: WP_VERSION=latest WC_VERSION=latest WP_MULTISITE=0 USE_COMPOSER=1 + env: WP_VERSION=latest WC_VERSION=latest WP_MULTISITE=0 after_success: bash <(curl -s https://codecov.io/bash) - php: 5.3 dist: precise From 0720148f9eb1dbf5af4581bfc54816da61999f83 Mon Sep 17 00:00:00 2001 From: Akolzin Dmitry Date: Tue, 3 Mar 2020 13:55:46 +0300 Subject: [PATCH 24/26] travis php7.3 --- .travis.yml | 2 +- tests/bin/install.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index fa9f318..1f5c3b8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,7 +25,7 @@ script: make test jobs: include: - php: 7.3 - env: WP_VERSION=latest WC_VERSION=latest WP_MULTISITE=0 + env: WP_VERSION=latest WC_VERSION=latest WP_MULTISITE=0 USE_COMPOSER=1 after_success: bash <(curl -s https://codecov.io/bash) - php: 5.3 dist: precise diff --git a/tests/bin/install.sh b/tests/bin/install.sh index ee83850..668cd80 100755 --- a/tests/bin/install.sh +++ b/tests/bin/install.sh @@ -82,13 +82,13 @@ install_woocommerce() { version=($(echo $WC_VERSION | tr "." "\n")) if [[ ${version[0]} -ge 3 && ${version[1]} -ge 7 ]]; then composer install - npm install +# npm install fi fi if [[ $WC_VERSION == 'latest' ]]; then composer install - npm install +# npm install fi cd - From 5e1f52a57ed94a75dd0c607735628d7ac230149e Mon Sep 17 00:00:00 2001 From: Akolzin Dmitry Date: Tue, 3 Mar 2020 14:28:16 +0300 Subject: [PATCH 25/26] github releases --- .travis.yml | 23 ++++++++++++++++++++--- README.md | 8 ++++++-- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1f5c3b8..eef7a08 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ if: tag IS blank stages: - test + - github releases - deploy before_script: @@ -24,9 +25,6 @@ script: make test jobs: include: - - php: 7.3 - env: WP_VERSION=latest WC_VERSION=latest WP_MULTISITE=0 USE_COMPOSER=1 - after_success: bash <(curl -s https://codecov.io/bash) - php: 5.3 dist: precise env: WP_VERSION=4.4 WC_VERSION=3.0.0 WP_MULTISITE=0 @@ -229,6 +227,8 @@ jobs: env: WP_VERSION=latest WC_VERSION=3.9.0 WP_MULTISITE=0 - php: 7.2 env: WP_VERSION=latest WC_VERSION=3.9.0 WP_MULTISITE=0 USE_COMPOSER=1 + - php: 7.3 + env: WP_VERSION=latest WC_VERSION=latest WP_MULTISITE=0 USE_COMPOSER=1 - php: 7.0 env: WP_VERSION=latest WC_VERSION=latest WP_MULTISITE=0 @@ -236,7 +236,24 @@ jobs: env: WP_VERSION=latest WC_VERSION=latest WP_MULTISITE=0 - php: 7.2 env: WP_VERSION=latest WC_VERSION=latest WP_MULTISITE=0 USE_COMPOSER=1 + - php: 7.3 + env: WP_VERSION=latest WC_VERSION=latest WP_MULTISITE=0 USE_COMPOSER=1 + after_success: bash <(curl -s https://codecov.io/bash) + - stage: github releases + before_deploy: + - export VERSION=`cat VERSION` + - git config --local user.name "retailCRM" + - git config --local user.email "support@retailcrm.ru" + - export TRAVIS_TAG=v$VERSION + - git tag $TRAVIS_TAG + deploy: + provider: releases + token: $GITHUB_OAUTH_TOKEN + cleanup: false + on: + condition: "$LAST_TAG != $CURRENT_VERSION" + if: branch = master AND type = push - stage: deploy deploy: cleanup: false diff --git a/README.md b/README.md index 3c4b834..bb9ceca 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,10 @@ Woocommerce-module ================== -Модуль интеграции с [retailCRM](http://retailcrm.ru) +Integration plugin for WooCommerce and [retailCRM](http://retailcrm.ru) -Информация о [кастомизации](https://github.com/retailcrm/woocommerce-module/wiki/%D0%9A%D0%B0%D1%81%D1%82%D0%BE%D0%BC%D0%B8%D0%B7%D0%B0%D1%86%D0%B8%D1%8F-%D0%B8%D0%BD%D1%82%D0%B5%D0%B3%D1%80%D0%B0%D1%86%D0%B8%D0%BE%D0%BD%D0%BD%D0%BE%D0%B3%D0%BE-%D0%BF%D0%BB%D0%B0%D0%B3%D0%B8%D0%BD%D0%B0) +[Customization](https://github.com/retailcrm/woocommerce-module/wiki/%D0%9A%D0%B0%D1%81%D1%82%D0%BE%D0%BC%D0%B8%D0%B7%D0%B0%D1%86%D0%B8%D1%8F-%D0%B8%D0%BD%D1%82%D0%B5%D0%B3%D1%80%D0%B0%D1%86%D0%B8%D0%BE%D0%BD%D0%BD%D0%BE%D0%B3%D0%BE-%D0%BF%D0%BB%D0%B0%D0%B3%D0%B8%D0%BD%D0%B0) info + +#### Local testing + +To local testing run `docker-compose up` From a877cf500c9830aabd0cfcd44993aed5dbf62de0 Mon Sep 17 00:00:00 2001 From: Akolzin Dmitry Date: Tue, 3 Mar 2020 15:29:48 +0300 Subject: [PATCH 26/26] update travis config --- .travis.yml | 4 +++- VERSION | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index eef7a08..15d33c0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -241,6 +241,8 @@ jobs: after_success: bash <(curl -s https://codecov.io/bash) - stage: github releases + before_script: skip + script: skip before_deploy: - export VERSION=`cat VERSION` - git config --local user.name "retailCRM" @@ -253,7 +255,7 @@ jobs: cleanup: false on: condition: "$LAST_TAG != $CURRENT_VERSION" - if: branch = master AND type = push + if: branch = master AND type = push AND fork = false - stage: deploy deploy: cleanup: false diff --git a/VERSION b/VERSION index 65afb3b..7d280e2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.5.4 +3.5.5