1
0
mirror of synced 2025-01-18 08:51:41 +03:00

Change the logic of the tests

This commit is contained in:
Dima Uryvskiy 2022-10-10 11:28:58 +03:00 committed by GitHub
parent 769907d812
commit 855ecc3aa7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 350 additions and 385 deletions

View File

@ -21,408 +21,237 @@ jobs:
matrix: matrix:
include: include:
# WordPress 5.3 # WordPress 5.3
#PHP 7.0 and 7.3
- php-version: '7.0' - php-version: '7.3'
wp: '5.3' wp: '5.3'
phpunit-version: 'phpunit:6.4.3'
wc: '5.4.3' wc: '5.4.3'
coverage: 1 coverage: 1
- php-version: '7.1'
wp: '5.3'
wc: '5.4.3'
- php-version: '7.2'
wp: '5.3'
wc: '5.4.3'
- php-version: '7.3' - php-version: '7.3'
wp: '5.3' wp: '5.3'
wc: '5.4.3' wc: '5.4.3'
- php-version: '7.0' - php-version: '7.0'
wp: '5.3' wp: '5.3'
wc: '5.5.3' wc: '6.4.0'
- php-version: '7.1'
wp: '5.3'
wc: '5.5.3'
- php-version: '7.2'
wp: '5.3'
wc: '5.5.3'
- php-version: '7.3' - php-version: '7.3'
wp: '5.3' wp: '5.3'
wc: '5.5.3' wc: '6.4.0'
- php-version: '7.0' #PHP 7.1 and 7.2
wp: '5.3'
wc: '5.6.1'
- php-version: '7.1'
wp: '5.3'
wc: '5.6.1'
- php-version: '7.2'
wp: '5.3'
wc: '5.6.1'
- php-version: '7.3'
wp: '5.3'
wc: '5.6.1'
- php-version: '7.0'
wp: '5.3'
wc: '5.7.1'
- php-version: '7.1'
wp: '5.3'
wc: '5.7.1'
- php-version: '7.2'
wp: '5.3'
wc: '5.7.1'
- php-version: '7.3'
wp: '5.3'
wc: '5.7.1'
- php-version: '7.0'
wp: '5.3'
wc: '5.8.0'
- php-version: '7.1' - php-version: '7.1'
wp: '5.3' wp: '5.3'
wc: '5.8.0' wc: '5.8.0'
- php-version: '7.2' - php-version: '7.2'
wp: '5.3' wp: '5.3'
wc: '5.8.0' wc: '5.8.0'
- php-version: '7.3' - php-version: '7.1'
wp: '5.3' wp: '5.3'
wc: '5.8.0' wc: '6.0.0'
## WordPress 5.4
- php-version: '7.0'
wp: '5.4'
wc: '5.4.3'
- php-version: '7.1'
wp: '5.4'
wc: '5.4.3'
- php-version: '7.2' - php-version: '7.2'
wp: '5.3'
wc: '6.0.0'
# WordPress 5.4
#PHP 7.0 and 7.3
- php-version: '7.3'
wp: '5.4' wp: '5.4'
wc: '5.4.3' wc: '5.4.3'
- php-version: '7.3' - php-version: '7.3'
wp: '5.4' wp: '5.4'
wc: '5.4.3' wc: '5.4.3'
- php-version: '7.0' - php-version: '7.0'
wp: '5.4' wp: '5.4'
wc: '5.5.3' wc: '6.4.0'
- php-version: '7.1'
wp: '5.4'
wc: '5.5.3'
- php-version: '7.2'
wp: '5.4'
wc: '5.5.3'
- php-version: '7.3' - php-version: '7.3'
wp: '5.4' wp: '5.4'
wc: '5.5.3' wc: '6.4.0'
- php-version: '7.0' #PHP 7.1 and 7.2
wp: '5.4'
wc: '5.6.1'
- php-version: '7.1'
wp: '5.4'
wc: '5.6.1'
- php-version: '7.2'
wp: '5.4'
wc: '5.6.1'
- php-version: '7.3'
wp: '5.4'
wc: '5.6.1'
- php-version: '7.0'
wp: '5.4'
wc: '5.7.1'
- php-version: '7.1'
wp: '5.4'
wc: '5.7.1'
- php-version: '7.2'
wp: '5.4'
wc: '5.7.1'
- php-version: '7.3'
wp: '5.4'
wc: '5.7.1'
- php-version: '7.0'
wp: '5.4'
wc: '5.8.0'
- php-version: '7.1' - php-version: '7.1'
wp: '5.4' wp: '5.4'
wc: '5.8.0' wc: '5.8.0'
- php-version: '7.2' - php-version: '7.2'
wp: '5.4' wp: '5.4'
wc: '5.8.0' wc: '5.8.0'
- php-version: '7.3' - php-version: '7.1'
wp: '5.4' wp: '5.4'
wc: '5.8.0' wc: '6.0.0'
## WordPress 5.5
- php-version: '7.0'
wp: '5.5'
wc: '5.4.3'
- php-version: '7.1'
wp: '5.5'
wc: '5.4.3'
- php-version: '7.2' - php-version: '7.2'
wp: '5.4'
wc: '6.0.0'
# WordPress 5.5
#PHP 7.0 and 7.3
- php-version: '7.3'
wp: '5.5' wp: '5.5'
wc: '5.4.3' wc: '5.4.3'
- php-version: '7.3' - php-version: '7.3'
wp: '5.5' wp: '5.5'
wc: '5.4.3' wc: '5.4.3'
- php-version: '7.0' - php-version: '7.0'
wp: '5.5' wp: '5.5'
wc: '5.5.3' wc: '6.4.0'
- php-version: '7.1'
wp: '5.5'
wc: '5.5.3'
- php-version: '7.2'
wp: '5.5'
wc: '5.5.3'
- php-version: '7.3' - php-version: '7.3'
wp: '5.5' wp: '5.5'
wc: '5.5.3' wc: '6.4.0'
- php-version: '7.0' #PHP 7.1 and 7.2
wp: '5.5'
wc: '5.6.1'
- php-version: '7.1'
wp: '5.5'
wc: '5.6.1'
- php-version: '7.2'
wp: '5.5'
wc: '5.6.1'
- php-version: '7.3'
wp: '5.5'
wc: '5.6.1'
- php-version: '7.0'
wp: '5.5'
wc: '5.7.1'
- php-version: '7.1'
wp: '5.5'
wc: '5.7.1'
- php-version: '7.2'
wp: '5.5'
wc: '5.7.1'
- php-version: '7.3'
wp: '5.5'
wc: '5.7.1'
- php-version: '7.0'
wp: '5.5'
wc: '5.8.0'
- php-version: '7.1' - php-version: '7.1'
wp: '5.5' wp: '5.5'
wc: '5.8.0' wc: '5.8.0'
- php-version: '7.2' - php-version: '7.2'
wp: '5.5' wp: '5.5'
wc: '5.8.0' wc: '5.8.0'
- php-version: '7.3'
wp: '5.5'
wc: '5.8.0'
## WordPress 5.6
- php-version: '7.0'
wp: '5.6'
wc: '5.4.3'
- php-version: '7.1' - php-version: '7.1'
wp: '5.6' wp: '5.5'
wc: '5.4.3' wc: '6.0.0'
- php-version: '7.2' - php-version: '7.2'
wp: '5.5'
wc: '6.0.0'
# WordPress 5.6
#PHP 7.0 and 7.3
- php-version: '7.3'
wp: '5.6' wp: '5.6'
wc: '5.4.3' wc: '5.4.3'
- php-version: '7.3' - php-version: '7.3'
wp: '5.6' wp: '5.6'
wc: '5.4.3' wc: '5.4.3'
- php-version: '7.0' - php-version: '7.0'
wp: '5.6' wp: '5.6'
wc: '5.5.3' wc: '6.4.0'
- php-version: '7.1'
wp: '5.6'
wc: '5.5.3'
- php-version: '7.2'
wp: '5.6'
wc: '5.5.3'
- php-version: '7.3' - php-version: '7.3'
wp: '5.6' wp: '5.6'
wc: '5.5.3' wc: '6.4.0'
- php-version: '7.0' #PHP 7.1 and 7.2
wp: '5.6'
wc: '5.6.1'
- php-version: '7.1'
wp: '5.6'
wc: '5.6.1'
- php-version: '7.2'
wp: '5.6'
wc: '5.6.1'
- php-version: '7.3'
wp: '5.6'
wc: '5.6.1'
- php-version: '7.0'
wp: '5.6'
wc: '5.7.1'
- php-version: '7.1'
wp: '5.6'
wc: '5.7.1'
- php-version: '7.2'
wp: '5.6'
wc: '5.7.1'
- php-version: '7.3'
wp: '5.6'
wc: '5.7.1'
- php-version: '7.0'
wp: '5.6'
wc: '5.8.0'
- php-version: '7.1' - php-version: '7.1'
wp: '5.6' wp: '5.6'
wc: '5.8.0' wc: '5.8.0'
- php-version: '7.2' - php-version: '7.2'
wp: '5.6' wp: '5.6'
wc: '5.8.0' wc: '5.8.0'
- php-version: '7.3'
wp: '5.6'
wc: '5.8.0'
## WordPress 5.7
- php-version: '7.0'
wp: '5.7'
wc: '5.4.3'
- php-version: '7.1' - php-version: '7.1'
wp: '5.7' wp: '5.6'
wc: '5.4.3' wc: '6.0.0'
- php-version: '7.2' - php-version: '7.2'
wp: '5.6'
wc: '6.0.0'
# WordPress 5.7
#PHP 7.0 and 7.3
- php-version: '7.3'
wp: '5.7' wp: '5.7'
wc: '5.4.3' wc: '5.4.3'
- php-version: '7.3' - php-version: '7.3'
wp: '5.7' wp: '5.7'
wc: '5.4.3' wc: '5.4.3'
- php-version: '7.0' - php-version: '7.0'
wp: '5.7' wp: '5.7'
wc: '5.5.3' wc: '6.4.0'
- php-version: '7.1'
wp: '5.7'
wc: '5.5.3'
- php-version: '7.2'
wp: '5.7'
wc: '5.5.3'
- php-version: '7.3' - php-version: '7.3'
wp: '5.7' wp: '5.7'
wc: '5.5.3' wc: '6.4.0'
- php-version: '7.0' #PHP 7.1 and 7.2
wp: '5.7'
wc: '5.6.1'
- php-version: '7.1'
wp: '5.7'
wc: '5.6.1'
- php-version: '7.2'
wp: '5.7'
wc: '5.6.1'
- php-version: '7.3'
wp: '5.7'
wc: '5.6.1'
- php-version: '7.0'
wp: '5.7'
wc: '5.7.1'
- php-version: '7.1'
wp: '5.7'
wc: '5.7.1'
- php-version: '7.2'
wp: '5.7'
wc: '5.7.1'
- php-version: '7.3'
wp: '5.7'
wc: '5.7.1'
- php-version: '7.0'
wp: '5.7'
wc: '5.8.0'
- php-version: '7.1' - php-version: '7.1'
wp: '5.7' wp: '5.7'
wc: '5.8.0' wc: '5.8.0'
- php-version: '7.2' - php-version: '7.2'
wp: '5.7' wp: '5.7'
wc: '5.8.0' wc: '5.8.0'
- php-version: '7.3'
wp: '5.7'
wc: '5.8.0'
## WordPress 5.8
- php-version: '7.0'
wp: '5.8'
wc: '5.4.3'
- php-version: '7.1' - php-version: '7.1'
wp: '5.8' wp: '5.7'
wc: '5.4.3' wc: '6.0.0'
- php-version: '7.2' - php-version: '7.2'
wp: '5.7'
wc: '6.0.0'
# WordPress 5.8
#PHP 7.0 and 7.3
- php-version: '7.3'
wp: '5.8' wp: '5.8'
wc: '5.4.3' wc: '5.4.3'
- php-version: '7.3' - php-version: '7.3'
wp: '5.8' wp: '5.8'
wc: '5.4.3' wc: '5.4.3'
- php-version: '7.0' - php-version: '7.0'
wp: '5.8' wp: '5.8'
wc: '5.5.3' wc: '6.4.0'
- php-version: '7.1'
wp: '5.8'
wc: '5.5.3'
- php-version: '7.2'
wp: '5.8'
wc: '5.5.3'
- php-version: '7.3' - php-version: '7.3'
wp: '5.8' wp: '5.8'
wc: '5.5.3' wc: '6.4.0'
- php-version: '7.0' #PHP 7.1 and 7.2
wp: '5.8'
wc: '5.6.1'
- php-version: '7.1'
wp: '5.8'
wc: '5.6.1'
- php-version: '7.2'
wp: '5.8'
wc: '5.6.1'
- php-version: '7.3'
wp: '5.8'
wc: '5.6.1'
- php-version: '7.0'
wp: '5.8'
wc: '5.7.1'
- php-version: '7.1'
wp: '5.8'
wc: '5.7.1'
- php-version: '7.2'
wp: '5.8'
wc: '5.7.1'
- php-version: '7.3'
wp: '5.8'
wc: '5.7.1'
- php-version: '7.0'
wp: '5.8'
wc: '5.8.0'
- php-version: '7.1' - php-version: '7.1'
wp: '5.8' wp: '5.8'
wc: '5.8.0' wc: '5.8.0'
- php-version: '7.2' - php-version: '7.2'
wp: '5.8' wp: '5.8'
wc: '5.8.0' wc: '5.8.0'
- php-version: '7.3' - php-version: '7.1'
wp: '5.8' wp: '5.8'
wc: '6.0.0'
- php-version: '7.2'
wp: '5.8'
wc: '6.0.0'
# WordPress 5.9
#PHP 7.0 and 7.3
- php-version: '7.3'
wp: '5.9'
wc: '5.4.3'
- php-version: '7.3'
wp: '5.9'
wc: '5.4.3'
- php-version: '7.0'
wp: '5.9'
wc: '6.4.0'
- php-version: '7.3'
wp: '5.9'
wc: '6.4.0'
#PHP 7.1 and 7.2
- php-version: '7.1'
wp: '5.9'
wc: '5.8.0' wc: '5.8.0'
- php-version: '7.2'
wp: '5.9'
wc: '5.8.0'
- php-version: '7.1'
wp: '5.9'
wc: '6.0.0'
- php-version: '7.2'
wp: '5.9'
wc: '6.0.0'
# WordPress 6.0
#PHP 7.0 and 7.3
- php-version: '7.3'
wp: '6.0'
wc: '5.4.3'
- php-version: '7.3'
wp: '6.0'
wc: '5.4.3'
- php-version: '7.0'
wp: '6.0'
wc: '6.4.0'
- php-version: '7.3'
wp: '6.0'
wc: '6.4.0'
#PHP 7.1 and 7.2
- php-version: '7.1'
wp: '6.0'
wc: '5.8.0'
- php-version: '7.2'
wp: '6.0'
wc: '5.8.0'
- php-version: '7.1'
wp: '6.0'
wc: '6.0.0'
- php-version: '7.2'
wp: '6.0'
wc: '6.0.0'
services: services:
mysql: mysql:
@ -450,6 +279,11 @@ jobs:
composer --version composer --version
phpunit --version phpunit --version
- name: Install Polyfills dependency for WP 5.9 and 6.0
if: ${{ matrix.wp }} == '6.0' || ${{ matrix.wp }} == '5.9'
run: |
composer require --dev yoast/phpunit-polyfills --ignore-platform-reqs
- name: Install Woocommerce - name: Install Woocommerce
env: env:
WP_VERSION: ${{ matrix.wp }} WP_VERSION: ${{ matrix.wp }}

View File

@ -16,7 +16,7 @@
"require-dev": { "require-dev": {
"ext-json": "*", "ext-json": "*",
"ext-mbstring": "*", "ext-mbstring": "*",
"ext-simplexml": "*", "phpunit/phpunit": "6.*",
"phpunit/phpunit": "6.*" "yoast/phpunit-polyfills": "1.x-dev"
} }
} }

78
composer.lock generated
View File

@ -1,10 +1,10 @@
{ {
"_readme": [ "_readme": [
"This file locks the dependencies of your project to a known state", "This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "07140d4f252afbd8967311bfadf35ede", "content-hash": "0352c9d2a1063ea65868246bee006dcb",
"packages": [], "packages": [],
"packages-dev": [ "packages-dev": [
{ {
@ -819,6 +819,7 @@
"mock", "mock",
"xunit" "xunit"
], ],
"abandoned": true,
"time": "2018-01-07T17:10:51+00:00" "time": "2018-01-07T17:10:51+00:00"
}, },
{ {
@ -1469,13 +1470,80 @@
"validate" "validate"
], ],
"time": "2018-04-19T15:46:26+00:00" "time": "2018-04-19T15:46:26+00:00"
},
{
"name": "yoast/phpunit-polyfills",
"version": "dev-develop",
"source": {
"type": "git",
"url": "https://github.com/Yoast/PHPUnit-Polyfills.git",
"reference": "b0c727ed3fb2a6c4528c676af69651ec4f579655"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Yoast/PHPUnit-Polyfills/zipball/b0c727ed3fb2a6c4528c676af69651ec4f579655",
"reference": "b0c727ed3fb2a6c4528c676af69651ec4f579655",
"shasum": ""
},
"require": {
"php": ">=5.4",
"phpunit/phpunit": "^4.8.36 || ^5.7.21 || ^6.0 || ^7.0 || ^8.0 || ^9.0"
},
"require-dev": {
"yoast/yoastcs": "^2.2.1"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "1.x-dev",
"dev-develop": "1.x-dev"
}
},
"autoload": {
"files": [
"phpunitpolyfills-autoload.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Team Yoast",
"email": "support@yoast.com",
"homepage": "https://yoast.com"
},
{
"name": "Contributors",
"homepage": "https://github.com/Yoast/PHPUnit-Polyfills/graphs/contributors"
}
],
"description": "Set of polyfills for changed PHPUnit functionality to allow for creating PHPUnit cross-version compatible tests",
"homepage": "https://github.com/Yoast/PHPUnit-Polyfills",
"keywords": [
"phpunit",
"polyfill",
"testing"
],
"time": "2022-08-03T05:59:50+00:00"
} }
], ],
"aliases": [], "aliases": [],
"minimum-stability": "dev", "minimum-stability": "dev",
"stability-flags": [], "stability-flags": {
"yoast/phpunit-polyfills": 20
},
"prefer-stable": false, "prefer-stable": false,
"prefer-lowest": false, "prefer-lowest": false,
"platform": [], "platform": {
"platform-dev": [] "ext-simplexml": "*",
"ext-xmlwriter": "*"
},
"platform-dev": {
"ext-json": "*",
"ext-mbstring": "*",
"ext-simplexml": "*"
},
"plugin-api-version": "1.1.0"
} }

View File

@ -104,6 +104,11 @@ if (!class_exists('WC_Retailcrm_History')) :
do { do {
$historyResponse = $this->retailcrm->customersHistory($filter); $historyResponse = $this->retailcrm->customersHistory($filter);
$isLastPage = $this->checkTotalPage($pagination, $historyResponse);
if ($isLastPage) {
break;
}
$history = $this->getHistoryData($historyResponse); $history = $this->getHistoryData($historyResponse);
@ -213,6 +218,11 @@ if (!class_exists('WC_Retailcrm_History')) :
do { do {
$historyResponse = $this->retailcrm->OrdersHistory($filter); $historyResponse = $this->retailcrm->OrdersHistory($filter);
$isLastPage = $this->checkTotalPage($pagination, $historyResponse);
if ($isLastPage) {
break;
}
$history = $this->getHistoryData($historyResponse); $history = $this->getHistoryData($historyResponse);
@ -1449,6 +1459,23 @@ if (!class_exists('WC_Retailcrm_History')) :
return $historyResponse['history']; return $historyResponse['history'];
} }
/**
* @param int $currentPage
* @param WC_Retailcrm_Response $historyResponse Responce from CRM
*
* @return bool
*/
private function checkTotalPage($currentPage, $historyResponse): bool
{
$totalPageCount = $historyResponse['pagination']['totalPageCount'] ?? null;
if (empty($totalPageCount)) {
return true;
}
return $currentPage > $totalPageCount;
}
} }
endif; endif;

View File

@ -8,7 +8,7 @@
* Version: 4.5.0 * Version: 4.5.0
* Tested up to: 6.0 * Tested up to: 6.0
* WC requires at least: 5.4 * WC requires at least: 5.4
* WC tested up to: 6.7 * WC tested up to: 6.9
* Text Domain: retailcrm * Text Domain: retailcrm
*/ */

View File

@ -57,8 +57,14 @@ install_woocommerce() {
git clone https://github.com/woocommerce/woocommerce.git git clone https://github.com/woocommerce/woocommerce.git
cd woocommerce cd woocommerce
git checkout $WC_VERSION git checkout $WC_VERSION
# In 6.x.x versions WooCommerce changed structure project, for install need move to plugins/woocommerce directory
if [[ "$WC_VERSION" =~ .*"6.".* ]]; then
cd plugins/woocommerce
fi;
composer install --ignore-platform-reqs composer install --ignore-platform-reqs
cd - cd /tmp
fi fi
} }

View File

@ -1,45 +1,75 @@
<?php <?php
$_tests_dir = getenv('WP_TESTS_DIR'); $wpVersion = getenv('WP_VERSION');
$_output_logs_to_stdout = getenv('MODULE_LOGS_TO_STDOUT');
$_wcOldBootstrap = '/tmp/woocommerce/tests/bootstrap.php';
$_wcNewBootstrap = '/tmp/woocommerce/tests/legacy/bootstrap.php';
if (!$_tests_dir) { if (empty($wpVersion)) {
$_tests_dir = '/tmp/wordpress-tests-lib'; die('WP version is empty!');
} }
require_once $_tests_dir . '/includes/functions.php'; $pluginDirectory = dirname(dirname(__FILE__)) . '/';
function _manually_load_plugin() { // Require for WP 5.9 and 6.0 versions
$plugin_dir = dirname(dirname(__FILE__)) . '/'; if ($wpVersion === '5.9' || $wpVersion === '6.0') {
echo 'Test';
require $plugin_dir . 'src/include/class-wc-retailcrm-orders.php'; require_once $pluginDirectory . 'vendor/yoast/phpunit-polyfills/phpunitpolyfills-autoload.php';
require $plugin_dir . 'src/include/class-wc-retailcrm-customers.php'; echo 'Test1';
require $plugin_dir . 'src/include/class-wc-retailcrm-inventories.php';
require $plugin_dir . 'src/include/class-wc-retailcrm-ga.php';
require $plugin_dir . 'src/include/class-wc-retailcrm-daemon-collector.php';
require $plugin_dir . 'src/include/class-wc-retailcrm-history.php';
require $plugin_dir . 'src/include/class-wc-retailcrm-icml.php';
require $plugin_dir . 'src/retailcrm.php';
} }
$testsDir = getenv('WP_TESTS_DIR');
if (!$testsDir) {
$testsDir = '/tmp/wordpress-tests-lib';
}
require_once $testsDir . '/includes/functions.php';
tests_add_filter('muplugins_loaded', '_manually_load_plugin'); tests_add_filter('muplugins_loaded', '_manually_load_plugin');
if (file_exists($_wcOldBootstrap)) { $wcVersion = getenv('WC_VERSION');
require $_wcOldBootstrap;
} elseif (file_exists($_wcNewBootstrap)) { if (empty($wcVersion)) {
require $_wcNewBootstrap; die('WC version is empty!');
} }
$plugin_dir = dirname(dirname(__FILE__)) . '/'; if ($wcVersion[0] === '6') {
$wcOldBootstrap = '/tmp/woocommerce/plugins/woocommerce/tests/bootstrap.php';
$wcNewBootstrap = '/tmp/woocommerce/plugins/woocommerce/tests/legacy/bootstrap.php';
} else {
$wcOldBootstrap = '/tmp/woocommerce/tests/bootstrap.php';
$wcNewBootstrap = '/tmp/woocommerce/tests/legacy/bootstrap.php';
}
if (file_exists($wcOldBootstrap)) {
require_once $wcOldBootstrap;
} elseif (file_exists($wcNewBootstrap)) {
require_once $wcNewBootstrap;
}
$outputLogsStdout = getenv('MODULE_LOGS_TO_STDOUT');
// helpers // helpers
require $plugin_dir . 'src/include/components/class-wc-retailcrm-logger.php'; require_once $pluginDirectory . 'src/include/components/class-wc-retailcrm-logger.php';
require $plugin_dir . 'tests/helpers/class-wc-retailcrm-response-helper.php'; require_once $pluginDirectory . 'tests/helpers/class-wc-retailcrm-response-helper.php';
require $plugin_dir . 'tests/helpers/class-wc-retailcrm-test-case-helper.php'; require_once $pluginDirectory . 'tests/helpers/class-wc-retailcrm-test-case-helper.php';
require $plugin_dir . 'tests/helpers/class-wc-retailcrm-log-handler-stdout.php'; require_once $pluginDirectory . 'tests/helpers/class-wc-retailcrm-log-handler-stdout.php';
if (!empty($_output_logs_to_stdout) && $_output_logs_to_stdout == '1') { if (!empty($outputLogsStdout) && $outputLogsStdout == '1') {
WC_Retailcrm_Logger::setAdditionalHandlers(array(new WC_Retailcrm_Log_Handler_Stdout())); WC_Retailcrm_Logger::setAdditionalHandlers([new WC_Retailcrm_Log_Handler_Stdout()]);
}
// Call after require WooCommerce bootstrap
function _manually_load_plugin()
{
$pluginDirectory = dirname(dirname(__FILE__)) . '/';
require_once $pluginDirectory . 'src/include/class-wc-retailcrm-customers.php';
require_once $pluginDirectory . 'src/include/class-wc-retailcrm-daemon-collector.php';
require_once $pluginDirectory . 'src/include/class-wc-retailcrm-ga.php';
require_once $pluginDirectory . 'src/include/class-wc-retailcrm-history.php';
require_once $pluginDirectory . 'src/include/class-wc-retailcrm-icml.php';
require_once $pluginDirectory . 'src/include/class-wc-retailcrm-inventories.php';
require_once $pluginDirectory . 'src/include/class-wc-retailcrm-orders.php';
require_once $pluginDirectory . 'src/include/class-wc-retailcrm-plugin.php';
require_once $pluginDirectory . 'src/include/class-wc-retailcrm-uploader.php';
require_once $pluginDirectory . 'src/retailcrm.php';
} }

View File

@ -116,7 +116,7 @@ class WC_Retailcrm_History_Test extends WC_Retailcrm_Test_Case_Helper
$retailcrm_history->getHistory(); $retailcrm_history->getHistory();
$orders = wc_get_orders(array( 'numberposts' => - 1 )); $orders = wc_get_orders(['numberposts' => - 1]);
$wcOrder = end($orders); $wcOrder = end($orders);
$options = get_option(\WC_Retailcrm_Base::$option_key); $options = get_option(\WC_Retailcrm_Base::$option_key);
@ -140,7 +140,7 @@ class WC_Retailcrm_History_Test extends WC_Retailcrm_Test_Case_Helper
$retailcrm_history = new \WC_Retailcrm_History($this->apiMock); $retailcrm_history = new \WC_Retailcrm_History($this->apiMock);
$retailcrm_history->getHistory(); $retailcrm_history->getHistory();
$orders = wc_get_orders(array('numberposts' => -1)); $orders = wc_get_orders(['numberposts' => -1]);
$order_added = end($orders); $order_added = end($orders);
if (!$order_added) { if (!$order_added) {
@ -433,7 +433,7 @@ class WC_Retailcrm_History_Test extends WC_Retailcrm_Test_Case_Helper
DataHistoryRetailCrm::get_order_with_customer_and_contact( DataHistoryRetailCrm::get_order_with_customer_and_contact(
DataHistoryRetailCrm::get_new_corporate_for_order(), DataHistoryRetailCrm::get_new_corporate_for_order(),
DataHistoryRetailCrm::get_new_contact_for_order(), DataHistoryRetailCrm::get_new_contact_for_order(),
array('name' => 'Компания1'), ['name' => 'Компания1'],
'legal-entity' 'legal-entity'
) )
); );
@ -496,7 +496,7 @@ class WC_Retailcrm_History_Test extends WC_Retailcrm_Test_Case_Helper
DataHistoryRetailCrm::get_order_with_customer_and_contact( DataHistoryRetailCrm::get_order_with_customer_and_contact(
DataHistoryRetailCrm::get_another_corporate_for_order(), DataHistoryRetailCrm::get_another_corporate_for_order(),
DataHistoryRetailCrm::get_another_contact_for_order(), DataHistoryRetailCrm::get_another_contact_for_order(),
array('name' => 'TestCompany3428769'), ['name' => 'TestCompany3428769'],
'legal-entity' 'legal-entity'
) )
); );
@ -560,7 +560,7 @@ class WC_Retailcrm_History_Test extends WC_Retailcrm_Test_Case_Helper
DataHistoryRetailCrm::get_order_with_customer_and_contact( DataHistoryRetailCrm::get_order_with_customer_and_contact(
DataHistoryRetailCrm::get_another_corporate_for_order(), DataHistoryRetailCrm::get_another_corporate_for_order(),
DataHistoryRetailCrm::get_another_contact_for_order(), DataHistoryRetailCrm::get_another_contact_for_order(),
array('name' => 'TestCompany017089465'), ['name' => 'TestCompany017089465'],
'legal-entity' 'legal-entity'
) )
); );
@ -624,7 +624,7 @@ class WC_Retailcrm_History_Test extends WC_Retailcrm_Test_Case_Helper
DataHistoryRetailCrm::get_order_with_customer_and_contact( DataHistoryRetailCrm::get_order_with_customer_and_contact(
DataHistoryRetailCrm::get_another_corporate_for_order(), DataHistoryRetailCrm::get_another_corporate_for_order(),
DataHistoryRetailCrm::get_contact_when_only_contact_changed(), DataHistoryRetailCrm::get_contact_when_only_contact_changed(),
array('name' => 'TestCompany017089465'), ['name' => 'TestCompany017089465'],
'legal-entity' 'legal-entity'
) )
); );
@ -798,17 +798,17 @@ class WC_Retailcrm_History_Test extends WC_Retailcrm_Test_Case_Helper
{ {
$this->apiMock = $this->getMockBuilder('\WC_Retailcrm_Proxy') $this->apiMock = $this->getMockBuilder('\WC_Retailcrm_Proxy')
->disableOriginalConstructor() ->disableOriginalConstructor()
->setMethods(array('ordersHistory', 'customersHistory', 'ordersGet')) ->setMethods(['ordersHistory', 'customersHistory', 'ordersGet'])
->getMock(); ->getMock();
$this->customersHistoryResponse = $this->getMockBuilder('\WC_Retailcrm_Response_Helper') $this->customersHistoryResponse = $this->getMockBuilder('\WC_Retailcrm_Response_Helper')
->disableOriginalConstructor() ->disableOriginalConstructor()
->setMethods(array('isSuccessful')) ->setMethods(['isSuccessful'])
->getMock(); ->getMock();
$this->ordersHistoryResponse = $this->getMockBuilder('\WC_Retailcrm_Response_Helper') $this->ordersHistoryResponse = $this->getMockBuilder('\WC_Retailcrm_Response_Helper')
->disableOriginalConstructor() ->disableOriginalConstructor()
->setMethods(array('isSuccessful')) ->setMethods(['isSuccessful'])
->getMock(); ->getMock();
} }
} }