diff --git a/.github/workflows/woo.yml b/.github/workflows/woo.yml index 6db7ec0..f661980 100644 --- a/.github/workflows/woo.yml +++ b/.github/workflows/woo.yml @@ -21,408 +21,237 @@ jobs: matrix: include: # WordPress 5.3 - - - php-version: '7.0' + #PHP 7.0 and 7.3 + - php-version: '7.3' wp: '5.3' - phpunit-version: 'phpunit:6.4.3' wc: '5.4.3' 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' wp: '5.3' wc: '5.4.3' - - php-version: '7.0' wp: '5.3' - wc: '5.5.3' - - php-version: '7.1' - wp: '5.3' - wc: '5.5.3' - - php-version: '7.2' - wp: '5.3' - wc: '5.5.3' + wc: '6.4.0' - php-version: '7.3' wp: '5.3' - wc: '5.5.3' + wc: '6.4.0' - - php-version: '7.0' - 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 7.1 and 7.2 - php-version: '7.1' wp: '5.3' wc: '5.8.0' - php-version: '7.2' wp: '5.3' wc: '5.8.0' - - php-version: '7.3' + - php-version: '7.1' wp: '5.3' - wc: '5.8.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' + wc: '6.0.0' - 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' wc: '5.4.3' - php-version: '7.3' wp: '5.4' wc: '5.4.3' - - php-version: '7.0' wp: '5.4' - wc: '5.5.3' - - php-version: '7.1' - wp: '5.4' - wc: '5.5.3' - - php-version: '7.2' - wp: '5.4' - wc: '5.5.3' + wc: '6.4.0' - php-version: '7.3' wp: '5.4' - wc: '5.5.3' + wc: '6.4.0' - - php-version: '7.0' - 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 7.1 and 7.2 - php-version: '7.1' wp: '5.4' wc: '5.8.0' - php-version: '7.2' wp: '5.4' wc: '5.8.0' - - php-version: '7.3' + - php-version: '7.1' wp: '5.4' - wc: '5.8.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' + wc: '6.0.0' - 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' wc: '5.4.3' - php-version: '7.3' wp: '5.5' wc: '5.4.3' - - php-version: '7.0' wp: '5.5' - wc: '5.5.3' - - php-version: '7.1' - wp: '5.5' - wc: '5.5.3' - - php-version: '7.2' - wp: '5.5' - wc: '5.5.3' + wc: '6.4.0' - php-version: '7.3' wp: '5.5' - wc: '5.5.3' + wc: '6.4.0' - - php-version: '7.0' - 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 7.1 and 7.2 - php-version: '7.1' wp: '5.5' wc: '5.8.0' - php-version: '7.2' wp: '5.5' 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' - wp: '5.6' - wc: '5.4.3' + wp: '5.5' + wc: '6.0.0' - 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' wc: '5.4.3' - php-version: '7.3' wp: '5.6' wc: '5.4.3' - - php-version: '7.0' wp: '5.6' - wc: '5.5.3' - - php-version: '7.1' - wp: '5.6' - wc: '5.5.3' - - php-version: '7.2' - wp: '5.6' - wc: '5.5.3' + wc: '6.4.0' - php-version: '7.3' wp: '5.6' - wc: '5.5.3' + wc: '6.4.0' - - php-version: '7.0' - 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 7.1 and 7.2 - php-version: '7.1' wp: '5.6' wc: '5.8.0' - php-version: '7.2' wp: '5.6' 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' - wp: '5.7' - wc: '5.4.3' + wp: '5.6' + wc: '6.0.0' - 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' wc: '5.4.3' - php-version: '7.3' wp: '5.7' wc: '5.4.3' - - php-version: '7.0' wp: '5.7' - wc: '5.5.3' - - php-version: '7.1' - wp: '5.7' - wc: '5.5.3' - - php-version: '7.2' - wp: '5.7' - wc: '5.5.3' + wc: '6.4.0' - php-version: '7.3' wp: '5.7' - wc: '5.5.3' + wc: '6.4.0' - - php-version: '7.0' - 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 7.1 and 7.2 - php-version: '7.1' wp: '5.7' wc: '5.8.0' - php-version: '7.2' wp: '5.7' 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' - wp: '5.8' - wc: '5.4.3' + wp: '5.7' + wc: '6.0.0' - 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' wc: '5.4.3' - php-version: '7.3' wp: '5.8' wc: '5.4.3' - - php-version: '7.0' wp: '5.8' - wc: '5.5.3' - - php-version: '7.1' - wp: '5.8' - wc: '5.5.3' - - php-version: '7.2' - wp: '5.8' - wc: '5.5.3' + wc: '6.4.0' - php-version: '7.3' wp: '5.8' - wc: '5.5.3' + wc: '6.4.0' - - php-version: '7.0' - 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 7.1 and 7.2 - php-version: '7.1' wp: '5.8' wc: '5.8.0' - php-version: '7.2' wp: '5.8' wc: '5.8.0' - - php-version: '7.3' + - php-version: '7.1' 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' + - 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: mysql: @@ -450,6 +279,11 @@ jobs: composer --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 env: WP_VERSION: ${{ matrix.wp }} @@ -517,4 +351,4 @@ jobs: make svn_push - name: Cleanup if: env.LAST_TAG != env.RELEASE_TAG - run: make remove_dir \ No newline at end of file + run: make remove_dir diff --git a/composer.json b/composer.json index afcdb46..680c858 100644 --- a/composer.json +++ b/composer.json @@ -10,13 +10,13 @@ ], "minimum-stability": "dev", "require": { - "ext-simplexml": "*", - "ext-xmlwriter": "*" + "ext-simplexml": "*", + "ext-xmlwriter": "*" }, "require-dev": { "ext-json": "*", "ext-mbstring": "*", - "ext-simplexml": "*", - "phpunit/phpunit": "6.*" + "phpunit/phpunit": "6.*", + "yoast/phpunit-polyfills": "1.x-dev" } } diff --git a/composer.lock b/composer.lock index e5541ba..9c71a62 100644 --- a/composer.lock +++ b/composer.lock @@ -1,10 +1,10 @@ { "_readme": [ "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" ], - "content-hash": "07140d4f252afbd8967311bfadf35ede", + "content-hash": "0352c9d2a1063ea65868246bee006dcb", "packages": [], "packages-dev": [ { @@ -819,6 +819,7 @@ "mock", "xunit" ], + "abandoned": true, "time": "2018-01-07T17:10:51+00:00" }, { @@ -1469,13 +1470,80 @@ "validate" ], "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": [], "minimum-stability": "dev", - "stability-flags": [], + "stability-flags": { + "yoast/phpunit-polyfills": 20 + }, "prefer-stable": false, "prefer-lowest": false, - "platform": [], - "platform-dev": [] + "platform": { + "ext-simplexml": "*", + "ext-xmlwriter": "*" + }, + "platform-dev": { + "ext-json": "*", + "ext-mbstring": "*", + "ext-simplexml": "*" + }, + "plugin-api-version": "1.1.0" } diff --git a/src/include/class-wc-retailcrm-history.php b/src/include/class-wc-retailcrm-history.php index 96cc2e9..e25eecc 100644 --- a/src/include/class-wc-retailcrm-history.php +++ b/src/include/class-wc-retailcrm-history.php @@ -104,6 +104,11 @@ if (!class_exists('WC_Retailcrm_History')) : do { $historyResponse = $this->retailcrm->customersHistory($filter); + $isLastPage = $this->checkTotalPage($pagination, $historyResponse); + + if ($isLastPage) { + break; + } $history = $this->getHistoryData($historyResponse); @@ -213,6 +218,11 @@ if (!class_exists('WC_Retailcrm_History')) : do { $historyResponse = $this->retailcrm->OrdersHistory($filter); + $isLastPage = $this->checkTotalPage($pagination, $historyResponse); + + if ($isLastPage) { + break; + } $history = $this->getHistoryData($historyResponse); @@ -1449,6 +1459,23 @@ if (!class_exists('WC_Retailcrm_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; diff --git a/src/retailcrm.php b/src/retailcrm.php index 6c5dfa7..0e4e5c2 100644 --- a/src/retailcrm.php +++ b/src/retailcrm.php @@ -8,7 +8,7 @@ * Version: 4.5.0 * Tested up to: 6.0 * WC requires at least: 5.4 - * WC tested up to: 6.7 + * WC tested up to: 6.9 * Text Domain: retailcrm */ diff --git a/tests/bin/install.sh b/tests/bin/install.sh index 73f503d..15378f8 100644 --- a/tests/bin/install.sh +++ b/tests/bin/install.sh @@ -12,19 +12,19 @@ WP_TESTS_DIR=${WP_TESTS_DIR-/tmp/wordpress-tests-lib} WP_CORE_DIR=${WP_CORE_DIR-/tmp/wordpress/} if [[ $WP_VERSION =~ [0-9]+\.[0-9]+(\.[0-9]+)? ]]; then - WP_TESTS_TAG="tags/$WP_VERSION" + WP_TESTS_TAG="tags/$WP_VERSION" elif [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then - WP_TESTS_TAG="trunk" + WP_TESTS_TAG="trunk" else - # http serves a single offer, whereas https serves multiple. we only want one - download http://api.wordpress.org/core/version-check/1.7/ /tmp/wp-latest.json - grep '[0-9]+\.[0-9]+(\.[0-9]+)?' /tmp/wp-latest.json - LATEST_VERSION=$(grep -o '"version":"[^"]*' /tmp/wp-latest.json | sed 's/"version":"//') - if [[ -z "$LATEST_VERSION" ]]; then - echo "Latest WordPress version could not be found" - exit 1 - fi - WP_TESTS_TAG="tags/$LATEST_VERSION" + # http serves a single offer, whereas https serves multiple. we only want one + download http://api.wordpress.org/core/version-check/1.7/ /tmp/wp-latest.json + grep '[0-9]+\.[0-9]+(\.[0-9]+)?' /tmp/wp-latest.json + LATEST_VERSION=$(grep -o '"version":"[^"]*' /tmp/wp-latest.json | sed 's/"version":"//') + if [[ -z "$LATEST_VERSION" ]]; then + echo "Latest WordPress version could not be found" + exit 1 + fi + WP_TESTS_TAG="tags/$LATEST_VERSION" fi set -ex @@ -38,15 +38,15 @@ download() { } install_wp() { - if [ -d $WP_CORE_DIR ]; then - return; - fi + if [ -d $WP_CORE_DIR ]; then + return; + fi - mkdir -p $WP_CORE_DIR - local ARCHIVE_NAME="wordpress-$WP_VERSION" - download https://wordpress.org/${ARCHIVE_NAME}.tar.gz /tmp/wordpress.tar.gz - tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR - download https://raw.github.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR/wp-content/db.php + mkdir -p $WP_CORE_DIR + local ARCHIVE_NAME="wordpress-$WP_VERSION" + download https://wordpress.org/${ARCHIVE_NAME}.tar.gz /tmp/wordpress.tar.gz + tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR + download https://raw.github.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR/wp-content/db.php } install_woocommerce() { @@ -57,37 +57,43 @@ install_woocommerce() { git clone https://github.com/woocommerce/woocommerce.git cd woocommerce 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 - cd - + cd /tmp fi } install_test_suite() { - # portable in-place argument for both GNU sed and Mac OSX sed - if [[ $(uname -s) == 'Darwin' ]]; then - local ioption='-i .bak' - else - local ioption='-i' - fi + # portable in-place argument for both GNU sed and Mac OSX sed + if [[ $(uname -s) == 'Darwin' ]]; then + local ioption='-i .bak' + else + local ioption='-i' + fi - # set up testing suite if it doesn't yet exist - if [ ! -d $WP_TESTS_DIR ]; then - # set up testing suite - mkdir -p $WP_TESTS_DIR - svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes - svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/data/ $WP_TESTS_DIR/data - fi + # set up testing suite if it doesn't yet exist + if [ ! -d $WP_TESTS_DIR ]; then + # set up testing suite + mkdir -p $WP_TESTS_DIR + svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes + svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/data/ $WP_TESTS_DIR/data + fi - if [ ! -f wp-tests-config.php ]; then - download https://develop.svn.wordpress.org/${WP_TESTS_TAG}/wp-tests-config-sample.php "$WP_TESTS_DIR"/wp-tests-config.php - # remove all forward slashes in the end - WP_CORE_DIR=$(echo $WP_CORE_DIR | sed "s:/\+$::") - sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR/':" "$WP_TESTS_DIR"/wp-tests-config.php - sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" "$WP_TESTS_DIR"/wp-tests-config.php - sed $ioption "s/yourusernamehere/$DB_USER/" "$WP_TESTS_DIR"/wp-tests-config.php - sed $ioption "s/yourpasswordhere/$DB_PASS/" "$WP_TESTS_DIR"/wp-tests-config.php - sed $ioption "s|localhost|${DB_HOST}|" "$WP_TESTS_DIR"/wp-tests-config.php - fi + if [ ! -f wp-tests-config.php ]; then + download https://develop.svn.wordpress.org/${WP_TESTS_TAG}/wp-tests-config-sample.php "$WP_TESTS_DIR"/wp-tests-config.php + # remove all forward slashes in the end + WP_CORE_DIR=$(echo $WP_CORE_DIR | sed "s:/\+$::") + sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR/':" "$WP_TESTS_DIR"/wp-tests-config.php + sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" "$WP_TESTS_DIR"/wp-tests-config.php + sed $ioption "s/yourusernamehere/$DB_USER/" "$WP_TESTS_DIR"/wp-tests-config.php + sed $ioption "s/yourpasswordhere/$DB_PASS/" "$WP_TESTS_DIR"/wp-tests-config.php + sed $ioption "s|localhost|${DB_HOST}|" "$WP_TESTS_DIR"/wp-tests-config.php + fi } install_db() { diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 093598d..c31a813 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,45 +1,75 @@ getHistory(); - $orders = wc_get_orders(array( 'numberposts' => - 1 )); + $orders = wc_get_orders(['numberposts' => - 1]); $wcOrder = end($orders); $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->getHistory(); - $orders = wc_get_orders(array('numberposts' => -1)); + $orders = wc_get_orders(['numberposts' => -1]); $order_added = end($orders); 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_new_corporate_for_order(), DataHistoryRetailCrm::get_new_contact_for_order(), - array('name' => 'Компания1'), + ['name' => 'Компания1'], '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_another_corporate_for_order(), DataHistoryRetailCrm::get_another_contact_for_order(), - array('name' => 'TestCompany3428769'), + ['name' => 'TestCompany3428769'], '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_another_corporate_for_order(), DataHistoryRetailCrm::get_another_contact_for_order(), - array('name' => 'TestCompany017089465'), + ['name' => 'TestCompany017089465'], '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_another_corporate_for_order(), DataHistoryRetailCrm::get_contact_when_only_contact_changed(), - array('name' => 'TestCompany017089465'), + ['name' => 'TestCompany017089465'], 'legal-entity' ) ); @@ -798,17 +798,17 @@ class WC_Retailcrm_History_Test extends WC_Retailcrm_Test_Case_Helper { $this->apiMock = $this->getMockBuilder('\WC_Retailcrm_Proxy') ->disableOriginalConstructor() - ->setMethods(array('ordersHistory', 'customersHistory', 'ordersGet')) + ->setMethods(['ordersHistory', 'customersHistory', 'ordersGet']) ->getMock(); $this->customersHistoryResponse = $this->getMockBuilder('\WC_Retailcrm_Response_Helper') ->disableOriginalConstructor() - ->setMethods(array('isSuccessful')) + ->setMethods(['isSuccessful']) ->getMock(); $this->ordersHistoryResponse = $this->getMockBuilder('\WC_Retailcrm_Response_Helper') ->disableOriginalConstructor() - ->setMethods(array('isSuccessful')) + ->setMethods(['isSuccessful']) ->getMock(); } }