1
0
mirror of synced 2025-01-19 01:11:42 +03:00

Merge pull request #120 from iyzoer/master

Travis build matrix
This commit is contained in:
Alex Lushpai 2020-03-03 17:51:53 +03:00 committed by GitHub
commit 0212ddf823
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 417 additions and 67 deletions

34
.docker/Dockerfile Normal file
View File

@ -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

6
.env-dist Normal file
View File

@ -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

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
/nbproject/ /nbproject/
/vendor/ /vendor/
.idea/ .idea/
.env

View File

@ -1,34 +1,264 @@
language: php os: linux
dist: trusty dist: trusty
sudo: false language: php
php: if: tag IS blank
- 5.6
- 7.0
- 7.1
env: stages:
- WP_VERSION=latest WP_MULTISITE=0 - test
- github releases
matrix: - deploy
fast_finish: true
include:
- php: 7.2
env: WP_VERSION=latest WP_MULTISITE=0 RUN_PHPCS=1
before_script: before_script:
- bash tests/bin/install.sh wc_retailcrm_test root '' localhost $WP_VERSION - nvm install 10
- make install
script: env:
- bash tests/bin/script.sh global:
- DB_NAME=wc_retailcrm_test
- DB_USER=root
- DB_PASS=''
- DB_HOST=localhost
deploy: script: make test
skip_cleanup: true
provider: script jobs:
script: make include:
on: - php: 5.3
php: 7.2 dist: precise
branch: master env: WP_VERSION=4.4 WC_VERSION=3.0.0 WP_MULTISITE=0
condition: "$DEPLOY = true" - 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

View File

@ -1,6 +1,8 @@
FILE = $(TRAVIS_BUILD_DIR)/VERSION FILE = $(TRAVIS_BUILD_DIR)/VERSION
VERSION = `cat $(FILE)` VERSION = `cat $(FILE)`
.PHONY: test
all: svn_clone svn_push remove_dir all: svn_clone svn_push remove_dir
svn_clone: svn_clone:
@ -20,3 +22,23 @@ svn_push: /tmp/svn_plugin_dir
remove_dir: remove_dir:
rm -rf /tmp/svn_plugin_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

View File

@ -5,6 +5,10 @@
Woocommerce-module 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`

View File

@ -1 +1 @@
3.5.4 3.5.5

View File

@ -11,6 +11,8 @@
"minimum-stability": "dev", "minimum-stability": "dev",
"require": {}, "require": {},
"require-dev": { "require-dev": {
"ext-json": "*",
"ext-mbstring": "*",
"phpunit/phpunit": "6.*" "phpunit/phpunit": "6.*"
} }
} }

34
docker-compose.yml Normal file
View File

@ -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"

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phpunit <phpunit
bootstrap="tests/phpunit/bootstrap.php" bootstrap="tests/bootstrap.php"
backupGlobals="false" backupGlobals="false"
colors="true" colors="true"
convertErrorsToExceptions="true" convertErrorsToExceptions="true"
@ -13,17 +13,21 @@
> >
<testsuites> <testsuites>
<testsuite name="Retailcrm WooCommerce Test Suite"> <testsuite name="Retailcrm WooCommerce Test Suite">
<directory suffix=".php">tests/phpunit</directory> <directory suffix=".php">tests</directory>
</testsuite> </testsuite>
</testsuites> </testsuites>
<filter> <filter>
<whitelist addUncoveredFilesFromWhitelist="true"> <whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src/include</directory> <directory suffix=".php">src</directory>
<exclude> <exclude>
<directory suffix=".php">src/include/api</directory> <directory suffix=".php">src/include/api</directory>
<file>src/retailcrm.php</file> <directory>src/config</directory>
<file>src/uninstall.php</file> <directory>src/languages</directory>
<file>src/readme.txt</file>
</exclude> </exclude>
</whitelist> </whitelist>
</filter> </filter>
<logging>
<log type="coverage-clover" target="coverage.xml"/>
</logging>
</phpunit> </phpunit>

View File

@ -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

View File

@ -353,13 +353,11 @@ if ( ! class_exists( 'WC_Retailcrm_History' ) ) :
$arItemsNew[$order_item_id] = $order_item_id; $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; $order['items'][$key]['woocomerceId'] = $result;
} else { } else {
foreach ($wc_order->get_items() as $order_item_id => $order_item) { foreach ($wc_order->get_items() as $order_item_id => $order_item) {
if ($order_item['variation_id'] != 0 ) { if ($order_item['variation_id'] != 0 ) {
$offer_id = $order_item['variation_id']; $offer_id = $order_item['variation_id'];
} else { } else {
@ -670,7 +668,7 @@ if ( ! class_exists( 'WC_Retailcrm_History' ) ) :
*/ */
protected function editOrder($settings, $wc_order, $order, $event = 'create') protected function editOrder($settings, $wc_order, $order, $event = 'create')
{ {
$order_items = []; $order_items = array();
if ($event == 'update') { if ($event == 'update') {
$result = $this->retailcrm->ordersGet($order['externalId']); $result = $this->retailcrm->ordersGet($order['externalId']);
if ($result->isSuccessful()) { if ($result->isSuccessful()) {
@ -702,10 +700,10 @@ if ( ! class_exists( 'WC_Retailcrm_History' ) ) :
} }
if (!empty($order_items)) { if (!empty($order_items)) {
$orderEdit = [ $orderEdit = array(
'id' => $order['id'], 'id' => $order['id'],
'items' => $order_items, 'items' => $order_items,
]; );
$this->retailcrm->ordersEdit($orderEdit, 'id'); $this->retailcrm->ordersEdit($orderEdit, 'id');
} }

View File

@ -8,10 +8,11 @@ fi
DB_NAME=$1 DB_NAME=$1
DB_USER=$2 DB_USER=$2
DB_PASS=$3 DB_HOST=${3-localhost}
DB_HOST=${4-localhost} WP_VERSION=${4-latest}
WP_VERSION=${5-latest} WC_VERSION=${5-3.9.0}
SKIP_DB_CREATE=${6-false} DB_PASS=${6-''}
SKIP_DB_CREATE=${7-false}
WP_TESTS_DIR=${WP_TESTS_DIR-/tmp/wordpress-tests-lib} WP_TESTS_DIR=${WP_TESTS_DIR-/tmp/wordpress-tests-lib}
WP_CORE_DIR=${WP_CORE_DIR-/tmp/wordpress/} WP_CORE_DIR=${WP_CORE_DIR-/tmp/wordpress/}
@ -69,13 +70,29 @@ install_wp() {
} }
install_woocommerce() { install_woocommerce() {
if [[ ! -d "/tmp/woocommerce" ]]
then
cd /tmp cd /tmp
git clone https://github.com/woocommerce/woocommerce.git git clone https://github.com/woocommerce/woocommerce.git
cd woocommerce cd woocommerce
git checkout master
composer install if [[ ! $WC_VERSION == 'latest' ]]; then
npm install 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 - cd -
fi
} }
install_test_suite() { install_test_suite() {
@ -129,8 +146,10 @@ install_db() {
fi fi
fi fi
# create database if [ ${DB_HOST} == "localhost" ]; then
mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA # create database
mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA --host=$DB_HOST
fi
} }
install_wp install_wp

View File

@ -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

View File

@ -9,7 +9,7 @@ if (!$_tests_dir) {
require_once $_tests_dir . '/includes/functions.php'; require_once $_tests_dir . '/includes/functions.php';
function _manually_load_plugin() { 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-orders.php';
require $plugin_dir . 'src/include/class-wc-retailcrm-customers.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'; require '/tmp/woocommerce/tests/bootstrap.php';
$plugin_dir = dirname(dirname(dirname(__FILE__))) . '/'; $plugin_dir = dirname(dirname(__FILE__)) . '/';
// helpers // helpers
require $plugin_dir . 'tests/helpers/class-wc-retailcrm-response-helper.php'; require $plugin_dir . 'tests/helpers/class-wc-retailcrm-response-helper.php';
require $plugin_dir . 'tests/helpers/class-wc-retailcrm-test-case-helper.php'; require $plugin_dir . 'tests/helpers/class-wc-retailcrm-test-case-helper.php';

View File

@ -106,7 +106,11 @@ class WC_Retailcrm_Orders_Test extends WC_Retailcrm_Test_Case_Helper
$this->assertEquals('Sormani', $order_send['lastName']); $this->assertEquals('Sormani', $order_send['lastName']);
$this->assertEquals('admin@example.org', $order_send['email']); $this->assertEquals('admin@example.org', $order_send['email']);
$this->assertEquals('US', $order_send['countryIso']); $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('WooCity', $order_send['delivery']['address']['city']);
$this->assertEquals('delivery', $order_send['delivery']['code']); $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('Sormani', $order_send['lastName']);
$this->assertEquals('admin@example.org', $order_send['email']); $this->assertEquals('admin@example.org', $order_send['email']);
$this->assertEquals('US', $order_send['countryIso']); $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('WooCity', $order_send['delivery']['address']['city']);
$this->assertEquals('delivery', $order_send['delivery']['code']); $this->assertEquals('delivery', $order_send['delivery']['code']);