1
0
mirror of synced 2025-01-18 17:01:41 +03:00
woocommerce-module/tests/bootstrap.php

76 lines
2.6 KiB
PHP
Raw Normal View History

<?php
2022-10-10 11:28:58 +03:00
$wpVersion = getenv('WP_VERSION');
2022-10-10 11:28:58 +03:00
if (empty($wpVersion)) {
die('WP version is empty!');
}
2022-10-10 11:28:58 +03:00
$pluginDirectory = dirname(dirname(__FILE__)) . '/';
2022-10-10 11:28:58 +03:00
// Require for WP 5.9 and 6.0 versions
if ($wpVersion === '5.9' || $wpVersion === '6.0') {
echo 'Test';
require_once $pluginDirectory . 'vendor/yoast/phpunit-polyfills/phpunitpolyfills-autoload.php';
echo 'Test1';
}
$testsDir = getenv('WP_TESTS_DIR');
2022-10-10 11:28:58 +03:00
if (!$testsDir) {
$testsDir = '/tmp/wordpress-tests-lib';
}
2022-10-10 11:28:58 +03:00
require_once $testsDir . '/includes/functions.php';
tests_add_filter('muplugins_loaded', '_manually_load_plugin');
2022-10-10 11:28:58 +03:00
$wcVersion = getenv('WC_VERSION');
if (empty($wcVersion)) {
die('WC version is empty!');
}
2022-10-10 11:28:58 +03:00
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
2022-10-10 11:28:58 +03:00
require_once $pluginDirectory . 'src/include/components/class-wc-retailcrm-logger.php';
require_once $pluginDirectory . 'tests/helpers/class-wc-retailcrm-response-helper.php';
require_once $pluginDirectory . 'tests/helpers/class-wc-retailcrm-test-case-helper.php';
require_once $pluginDirectory . 'tests/helpers/class-wc-retailcrm-log-handler-stdout.php';
if (!empty($outputLogsStdout) && $outputLogsStdout == '1') {
WC_Retailcrm_Logger::setAdditionalHandlers([new WC_Retailcrm_Log_Handler_Stdout()]);
}
// Call after require WooCommerce bootstrap
function _manually_load_plugin()
{
$pluginDirectory = dirname(dirname(__FILE__)) . '/';
2022-10-10 11:28:58 +03:00
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';
}