mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-30 05:00:51 +08:00
Fix tests.
This commit is contained in:
parent
1a21ef0d21
commit
838449251f
2 changed files with 42 additions and 0 deletions
|
@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||
define('TESTS_ROOT_DIR', dirname(__DIR__));
|
||||
define('ROOT_DIR', dirname(TESTS_ROOT_DIR));
|
||||
|
||||
require_once TESTS_ROOT_DIR . '/inc/wp_functions.php';
|
||||
require_once ROOT_DIR . '/vendor/autoload.php';
|
||||
require_once TESTS_ROOT_DIR . '/stubs/WC_Payment_Gateway.php';
|
||||
require_once TESTS_ROOT_DIR . '/stubs/WC_Payment_Gateway_CC.php';
|
||||
|
|
41
tests/inc/wp_functions.php
Normal file
41
tests/inc/wp_functions.php
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
if ( ! file_exists( 'wp_normalize_path' ) ) {
|
||||
function wp_is_stream( $path ) {
|
||||
$scheme_separator = strpos( $path, '://' );
|
||||
|
||||
if ( false === $scheme_separator ) {
|
||||
// $path isn't a stream.
|
||||
return false;
|
||||
}
|
||||
|
||||
$stream = substr( $path, 0, $scheme_separator );
|
||||
|
||||
return in_array( $stream, stream_get_wrappers(), true );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! file_exists( 'wp_normalize_path' ) ) {
|
||||
function wp_normalize_path( $path ) {
|
||||
$wrapper = '';
|
||||
|
||||
if ( wp_is_stream( $path ) ) {
|
||||
list( $wrapper, $path ) = explode( '://', $path, 2 );
|
||||
|
||||
$wrapper .= '://';
|
||||
}
|
||||
|
||||
// Standardize all paths to use '/'.
|
||||
$path = str_replace( '\\', '/', $path );
|
||||
|
||||
// Replace multiple slashes down to a singular, allowing for network shares having two slashes.
|
||||
$path = preg_replace( '|(?<=.)/+|', '/', $path );
|
||||
|
||||
// Windows paths should uppercase the drive letter.
|
||||
if ( ':' === substr( $path, 1, 1 ) ) {
|
||||
$path = ucfirst( $path );
|
||||
}
|
||||
|
||||
return $wrapper . $path;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue