diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cc3e792dc5da59fdb3daa3a589e375875b10b581..56eaf419b75b9158966f9e6cd495eca639058c1e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,8 +1,7 @@ variables: DISABLE_PHP_5_5: 1 - DISABLE_UNIT_TESTS: 1 + DISABLE_UNIT: 1 DISABLE_INTEGRATION_TESTS: 1 DISABLE_CODECEPTION: 1 - IS_LIBRARY: 1 include: 'https://gitlab.com/wpdesk/gitlab-ci/raw/master/gitlab-ci-1.2.yml' diff --git a/WPDeskPlugin/rulests.xml b/WPDeskPlugin/rulest.xml similarity index 100% rename from WPDeskPlugin/rulests.xml rename to WPDeskPlugin/rulest.xml diff --git a/tests/integration/bootstrap.php b/tests/integration/bootstrap.php new file mode 100644 index 0000000000000000000000000000000000000000..35315e4a86b379cf1bf6306ecb8de2a73fc641f3 --- /dev/null +++ b/tests/integration/bootstrap.php @@ -0,0 +1,38 @@ +<?php + +ini_set('error_reporting', E_ALL); // or error_reporting(E_ALL); +ini_set('display_errors', '1'); +ini_set('display_startup_errors', '1'); + +// disable xdebug backtrace +if ( function_exists( 'xdebug_disable' ) ) { + xdebug_disable(); +} + +if ( getenv( 'PLUGIN_PATH' ) !== false ) { + define( 'PLUGIN_PATH', getenv( 'PLUGIN_PATH' ) ); +} else { + define( 'PLUGIN_PATH', __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR ); +} + +require_once( getenv( 'WP_DEVELOP_DIR' ) . '/tests/phpunit/includes/functions.php' ); + +tests_add_filter( 'muplugins_loaded', function () { + require PLUGIN_PATH . '/woocommerce-fakturownia.php'; + $plugins_to_active[] = 'woocommerce-fakturownia/woocommerce-fakturownia.php'; + update_option( 'active_plugins', $plugins_to_active ); +}, 100 ); + +putenv('WP_TESTS_DIR=' . getenv( 'WP_DEVELOP_DIR' ) . '/tests/phpunit'); +require_once( getenv( 'WC_DEVELOP_DIR' ) . '/tests/bootstrap.php' ); + +$plugins_to_active = get_option( 'active_plugins' ); +$plugins_to_active[] = 'woocommerce/woocommerce.php'; +update_option( 'active_plugins', $plugins_to_active ); + +do_action('plugins_loaded'); + +echo "\n\n"; +echo 'WC_VERSION=' . WC_VERSION . "\n"; +echo 'PHP_VERSION=' . phpversion() . "\n"; +echo "\n\n"; diff --git a/tests/unit/bootstrap.php b/tests/unit/bootstrap.php new file mode 100644 index 0000000000000000000000000000000000000000..e55059f69f9265d81aa3a4afa8c679633a5a6ad9 --- /dev/null +++ b/tests/unit/bootstrap.php @@ -0,0 +1,23 @@ +<?php +/** + * PHPUnit bootstrap file + */ + +require_once __DIR__ . '/../../vendor/autoload.php'; + +error_reporting( E_ALL ); + +if ( getenv( 'PLUGIN_PATH' ) !== false ) { + define( 'PLUGIN_PATH', getenv( 'PLUGIN_PATH' ) ); +} else { + define( 'PLUGIN_PATH', __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR ); +} + +if ( getenv( 'ABSPATH' ) !== false ) { + define( 'ABSPATH', getenv( 'ABSPATH' ) ); +} else { + define( 'ABSPATH', PLUGIN_PATH . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR ); +} + +WP_Mock::setUsePatchwork( true ); +WP_Mock::bootstrap();