diff --git a/tests/bootstrap.php b/tests/bootstrap.php index bb7b0c8..50207bc 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -39,4 +39,21 @@ 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-log-handler-stdout.php'; -WC_Retailcrm_Logger::setAdditionalHandlers(array(new WC_Retailcrm_Log_Handler_Stdout())); \ No newline at end of file +WC_Retailcrm_Logger::setAdditionalHandlers(array(new WC_Retailcrm_Log_Handler_Stdout())); + +/** + * Returns true if WP version is 4.6 or older. It's useful in some tests. + * + * @return bool + */ +function is_wp_older_or_4_6() { + include(ABSPATH . WPINC . '/version.php'); + + if (!empty($wp_version)) { + $version = explode('.', substr($wp_version, 0, 3)); + + return count($version) == 2 && ($version[0] > 4 || $version[1] > 6); + } + + return true; +} diff --git a/tests/test-wc-retailcrm-history.php b/tests/test-wc-retailcrm-history.php index 277701f..3ad9625 100644 --- a/tests/test-wc-retailcrm-history.php +++ b/tests/test-wc-retailcrm-history.php @@ -296,7 +296,10 @@ class WC_Retailcrm_History_Test extends WC_Retailcrm_Test_Case_Helper $this->assertEquals('Еврейская Автономная область', $order->get_billing_state()); $this->assertEquals('Компания1', $order->get_billing_company()); $this->assertEquals('9135487458709', $order->get_billing_phone()); - $this->assertEmpty($order->get_customer_id()); + + if (!is_wp_older_or_4_6()) { + $this->assertEmpty($order->get_customer_id()); + } } /**