|
1 | 1 | <?php |
2 | 2 |
|
3 | | -// Configure the test environment. |
4 | | -error_reporting( E_ALL ); |
5 | | -define( 'FQDB', ':memory:' ); |
6 | | -define( 'FQDBDIR', __DIR__ . '/../testdb' ); |
7 | | - |
| 3 | +require_once __DIR__ . '/../php-polyfills.php'; |
8 | 4 | require_once __DIR__ . '/wp-sqlite-schema.php'; |
9 | | -require_once __DIR__ . '/../constants.php'; |
10 | 5 | require_once __DIR__ . '/../wp-pdo-mysql-on-sqlite.php'; |
11 | 6 | require_once __DIR__ . '/../wp-includes/sqlite/class-wp-sqlite-query-rewriter.php'; |
12 | 7 | require_once __DIR__ . '/../wp-includes/sqlite/class-wp-sqlite-lexer.php'; |
|
20 | 15 | define( 'WP_SQLITE_UNSAFE_ENABLE_UNSUPPORTED_VERSIONS', true ); |
21 | 16 | } |
22 | 17 |
|
| 18 | +// Configure the test environment. |
| 19 | +error_reporting( E_ALL ); |
| 20 | +define( 'FQDB', ':memory:' ); |
| 21 | +define( 'FQDBDIR', __DIR__ . '/../testdb' ); |
| 22 | + |
23 | 23 | // Polyfill WPDB globals. |
24 | 24 | $GLOBALS['table_prefix'] = 'wptests_'; |
25 | 25 | $GLOBALS['wpdb'] = new class() { |
@@ -51,57 +51,6 @@ function apply_filters( $tag, $value, ...$args ) { |
51 | 51 | } |
52 | 52 | } |
53 | 53 |
|
54 | | -/** |
55 | | - * Polyfills for php 7 & 8 functions |
56 | | - */ |
57 | | - |
58 | | -if ( ! function_exists( 'str_starts_with' ) ) { |
59 | | - /** |
60 | | - * Check if a string starts with a specific substring. |
61 | | - * |
62 | | - * @param string $haystack The string to search in. |
63 | | - * @param string $needle The string to search for. |
64 | | - * |
65 | | - * @see https://www.php.net/manual/en/function.str-starts-with |
66 | | - * |
67 | | - * @return bool |
68 | | - */ |
69 | | - function str_starts_with( string $haystack, string $needle ) { |
70 | | - return empty( $needle ) || 0 === strpos( $haystack, $needle ); |
71 | | - } |
72 | | -} |
73 | | - |
74 | | -if ( ! function_exists( 'str_contains' ) ) { |
75 | | - /** |
76 | | - * Check if a string contains a specific substring. |
77 | | - * |
78 | | - * @param string $haystack The string to search in. |
79 | | - * @param string $needle The string to search for. |
80 | | - * |
81 | | - * @see https://www.php.net/manual/en/function.str-contains |
82 | | - * |
83 | | - * @return bool |
84 | | - */ |
85 | | - function str_contains( string $haystack, string $needle ) { |
86 | | - return empty( $needle ) || false !== strpos( $haystack, $needle ); |
87 | | - } |
88 | | -} |
89 | | - |
90 | | -if ( ! function_exists( 'str_ends_with' ) ) { |
91 | | - /** |
92 | | - * Check if a string ends with a specific substring. |
93 | | - * |
94 | | - * @param string $haystack The string to search in. |
95 | | - * @param string $needle The string to search for. |
96 | | - * |
97 | | - * @see https://www.php.net/manual/en/function.str-ends-with |
98 | | - * |
99 | | - * @return bool |
100 | | - */ |
101 | | - function str_ends_with( string $haystack, string $needle ) { |
102 | | - return empty( $needle ) || substr( $haystack, -strlen( $needle ) ) === $needle; |
103 | | - } |
104 | | -} |
105 | 54 | if ( extension_loaded( 'mbstring' ) ) { |
106 | 55 |
|
107 | 56 | if ( ! function_exists( 'mb_str_starts_with' ) ) { |
|
0 commit comments