@@ -1,28 +1,28 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -$_tests_dir = getenv( 'WP_TESTS_DIR' ); |
|
| 4 | -if ( ! $_tests_dir ) { |
|
| 3 | +$_tests_dir = getenv('WP_TESTS_DIR'); |
|
| 4 | +if ( ! $_tests_dir) { |
|
| 5 | 5 | $_tests_dir = '/tmp/wordpress-tests-lib'; |
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | require_once $_tests_dir . '/includes/functions.php'; |
| 9 | 9 | |
| 10 | 10 | function _manually_load_plugin() { |
| 11 | - $plugin_dir = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/'; |
|
| 11 | + $plugin_dir = dirname(dirname(dirname(dirname(__FILE__)))) . '/'; |
|
| 12 | 12 | require $plugin_dir . 'woocommerce/woocommerce.php'; |
| 13 | 13 | require $plugin_dir . 'woocommerce-gateway-stripe/woocommerce-gateway-stripe.php'; |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | -tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' ); |
|
| 16 | +tests_add_filter('muplugins_loaded', '_manually_load_plugin'); |
|
| 17 | 17 | |
| 18 | 18 | require $_tests_dir . '/includes/bootstrap.php'; |
| 19 | 19 | |
| 20 | -$wc_tests_framework_base_dir = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/woocommerce/tests/framework/'; |
|
| 21 | -require_once( $wc_tests_framework_base_dir . 'class-wc-mock-session-handler.php' ); |
|
| 22 | -require_once( $wc_tests_framework_base_dir . 'class-wc-unit-test-case.php' ); |
|
| 23 | -require_once( $wc_tests_framework_base_dir . 'helpers/class-wc-helper-product.php' ); |
|
| 24 | -require_once( $wc_tests_framework_base_dir . 'helpers/class-wc-helper-coupon.php' ); |
|
| 25 | -require_once( $wc_tests_framework_base_dir . 'helpers/class-wc-helper-fee.php' ); |
|
| 26 | -require_once( $wc_tests_framework_base_dir . 'helpers/class-wc-helper-shipping.php' ); |
|
| 27 | -require_once( $wc_tests_framework_base_dir . 'helpers/class-wc-helper-customer.php' ); |
|
| 28 | -require_once( $wc_tests_framework_base_dir . 'helpers/class-wc-helper-order.php' ); |
|
| 20 | +$wc_tests_framework_base_dir = dirname(dirname(dirname(dirname(__FILE__)))) . '/woocommerce/tests/framework/'; |
|
| 21 | +require_once($wc_tests_framework_base_dir . 'class-wc-mock-session-handler.php'); |
|
| 22 | +require_once($wc_tests_framework_base_dir . 'class-wc-unit-test-case.php'); |
|
| 23 | +require_once($wc_tests_framework_base_dir . 'helpers/class-wc-helper-product.php'); |
|
| 24 | +require_once($wc_tests_framework_base_dir . 'helpers/class-wc-helper-coupon.php'); |
|
| 25 | +require_once($wc_tests_framework_base_dir . 'helpers/class-wc-helper-fee.php'); |
|
| 26 | +require_once($wc_tests_framework_base_dir . 'helpers/class-wc-helper-shipping.php'); |
|
| 27 | +require_once($wc_tests_framework_base_dir . 'helpers/class-wc-helper-customer.php'); |
|
| 28 | +require_once($wc_tests_framework_base_dir . 'helpers/class-wc-helper-order.php'); |
|
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 2 | +if ( ! defined('ABSPATH')) { |
|
| 3 | 3 | exit; // Exit if accessed directly |
| 4 | 4 | } |
| 5 | 5 | |
@@ -20,32 +20,32 @@ discard block |
||
| 20 | 20 | * @since 4.0.0 |
| 21 | 21 | * @version 4.0.0 |
| 22 | 22 | */ |
| 23 | - public static function log( $message, $start_time = null, $end_time = null ) { |
|
| 24 | - if ( ! class_exists( 'WC_Logger' ) ) { |
|
| 23 | + public static function log($message, $start_time = null, $end_time = null) { |
|
| 24 | + if ( ! class_exists('WC_Logger')) { |
|
| 25 | 25 | return; |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | - if ( apply_filters( 'wc_stripe_logging', true, $message ) ) { |
|
| 29 | - if ( empty( self::$logger ) ) { |
|
| 30 | - if ( version_compare( WC_VERSION, '3.0.0', '>=' ) ) { |
|
| 28 | + if (apply_filters('wc_stripe_logging', true, $message)) { |
|
| 29 | + if (empty(self::$logger)) { |
|
| 30 | + if (version_compare(WC_VERSION, '3.0.0', '>=')) { |
|
| 31 | 31 | self::$logger = wc_get_logger(); |
| 32 | 32 | } else { |
| 33 | 33 | self::$logger = new WC_Logger(); |
| 34 | 34 | } |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - $settings = get_option( 'woocommerce_stripe_settings' ); |
|
| 37 | + $settings = get_option('woocommerce_stripe_settings'); |
|
| 38 | 38 | |
| 39 | - if ( empty( $settings ) || isset( $settings['logging'] ) && 'yes' !== $settings['logging'] ) { |
|
| 39 | + if (empty($settings) || isset($settings['logging']) && 'yes' !== $settings['logging']) { |
|
| 40 | 40 | return; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - if ( ! is_null( $start_time ) ) { |
|
| 43 | + if ( ! is_null($start_time)) { |
|
| 44 | 44 | |
| 45 | - $formatted_start_time = date_i18n( get_option( 'date_format' ) . ' g:ia', $start_time ); |
|
| 46 | - $end_time = is_null( $end_time ) ? current_time( 'timestamp' ) : $end_time; |
|
| 47 | - $formatted_end_time = date_i18n( get_option( 'date_format' ) . ' g:ia', $end_time ); |
|
| 48 | - $elapsed_time = round( abs( $end_time - $start_time ) / 60, 2 ); |
|
| 45 | + $formatted_start_time = date_i18n(get_option('date_format') . ' g:ia', $start_time); |
|
| 46 | + $end_time = is_null($end_time) ? current_time('timestamp') : $end_time; |
|
| 47 | + $formatted_end_time = date_i18n(get_option('date_format') . ' g:ia', $end_time); |
|
| 48 | + $elapsed_time = round(abs($end_time - $start_time) / 60, 2); |
|
| 49 | 49 | |
| 50 | 50 | $log_entry = "\n" . '====Stripe Version: ' . WC_STRIPE_VERSION . '====' . "\n"; |
| 51 | 51 | $log_entry .= '====Start Log ' . $formatted_start_time . '====' . "\n" . $message . "\n"; |
@@ -57,10 +57,10 @@ discard block |
||
| 57 | 57 | |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - if ( version_compare( WC_VERSION, '3.0.0', '>=' ) ) { |
|
| 61 | - self::$logger->debug( $log_entry, array( 'source' => self::WC_LOG_FILENAME ) ); |
|
| 60 | + if (version_compare(WC_VERSION, '3.0.0', '>=')) { |
|
| 61 | + self::$logger->debug($log_entry, array('source' => self::WC_LOG_FILENAME)); |
|
| 62 | 62 | } else { |
| 63 | - self::$logger->add( self::WC_LOG_FILENAME, $log_entry ); |
|
| 63 | + self::$logger->add(self::WC_LOG_FILENAME, $log_entry); |
|
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | } |