diff --git a/.docker/Dockerfile b/.docker/Dockerfile new file mode 100644 index 0000000..cb967eb --- /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-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 - +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 db239f2..15d33c0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,34 +1,264 @@ -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 + - github releases + - deploy before_script: - - bash tests/bin/install.sh wc_retailcrm_test root '' localhost $WP_VERSION + - nvm install 10 + - make install -script: - - bash tests/bin/script.sh +env: + global: + - DB_NAME=wc_retailcrm_test + - DB_USER=root + - DB_PASS='' + - DB_HOST=localhost -deploy: - skip_cleanup: true - provider: script - script: make - on: - php: 7.2 - branch: master - condition: "$DEPLOY = true" +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 + 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 + env: WP_VERSION=4.8 WC_VERSION=3.3.0 WP_MULTISITE=0 + - php: 7.1 + env: WP_VERSION=4.8 WC_VERSION=3.3.0 WP_MULTISITE=0 + - 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 + 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: 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 + - php: 7.1 + 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_script: skip + script: skip + 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 AND fork = false + - 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..fb8f0c9 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,8 @@ FILE = $(TRAVIS_BUILD_DIR)/VERSION VERSION = `cat $(FILE)` +.PHONY: test + all: svn_clone svn_push remove_dir svn_clone: @@ -20,3 +22,23 @@ 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 $(DB_NAME) $(DB_USER) $(DB_HOST) $(WP_VERSION) $(WC_VERSION) $(DB_PASS) $(SKIP_DB_CREATE) +ifeq ($(USE_COMPOSER),1) + composer install +endif + +test: +ifeq ($(USE_COMPOSER),1) + vendor/phpunit/phpunit/phpunit -c phpunit.xml.dist +else + phpunit -c phpunit.xml.dist +endif + +local_test: install + phpunit -c phpunit.xml.dist 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` diff --git a/VERSION b/VERSION index 65afb3b..7d280e2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.5.4 +3.5.5 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/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..48ed647 --- /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/phpunit.xml.dist b/phpunit.xml.dist index 8057fd7..6fb729f 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,6 +1,6 @@ - tests/phpunit + tests - 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/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/src/include/class-wc-retailcrm-history.php b/src/include/class-wc-retailcrm-history.php index b38fa86..ff732ea 100644 --- a/src/include/class-wc-retailcrm-history.php +++ b/src/include/class-wc-retailcrm-history.php @@ -353,13 +353,11 @@ 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) { - - - if ($order_item['variation_id'] != 0 ) { $offer_id = $order_item['variation_id']; } else { @@ -670,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()) { @@ -702,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'); } diff --git a/tests/bin/install.sh b/tests/bin/install.sh index d3ca88c..668cd80 100755 --- a/tests/bin/install.sh +++ b/tests/bin/install.sh @@ -8,10 +8,11 @@ fi DB_NAME=$1 DB_USER=$2 -DB_PASS=$3 -DB_HOST=${4-localhost} -WP_VERSION=${5-latest} -SKIP_DB_CREATE=${6-false} +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} WP_CORE_DIR=${WP_CORE_DIR-/tmp/wordpress/} @@ -69,13 +70,29 @@ install_wp() { } install_woocommerce() { + if [[ ! -d "/tmp/woocommerce" ]] + then cd /tmp git clone https://github.com/woocommerce/woocommerce.git cd woocommerce - git checkout master - composer install - npm install + + if [[ ! $WC_VERSION == 'latest' ]]; then + git checkout $WC_VERSION + + version=($(echo $WC_VERSION | tr "." "\n")) + if [[ ${version[0]} -ge 3 && ${version[1]} -ge 7 ]]; then + composer install +# npm install + fi + fi + + if [[ $WC_VERSION == 'latest' ]]; then + composer install +# npm install + fi + cd - + fi } install_test_suite() { @@ -129,8 +146,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 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 89% rename from tests/phpunit/bootstrap.php rename to tests/bootstrap.php index f531b62..ed438a0 100644 --- a/tests/phpunit/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'; @@ -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'; 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 95% rename from tests/phpunit/test-wc-retailcrm-orders.php rename to tests/test-wc-retailcrm-orders.php index b7df534..bda8a84 100644 --- a/tests/phpunit/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']); 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