Skip to content

Commit 9239cff

Browse files
authored
Update tests to accommodate for SQLite (#5849)
* Skip some tests on SQLite * Skip tests * Skip another test * Skip test * Ensure stable sort for list of found prefixes
1 parent 10e58af commit 9239cff

File tree

8 files changed

+37
-6
lines changed

8 files changed

+37
-6
lines changed

features/bootstrap.feature

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ Feature: Bootstrap WP-CLI
367367
define( 'WP_CLI_TEST_CONSTANT', getenv( 'WP_CLI_TEST_ENV_VAR' ) );
368368
"""
369369

370-
When I run `wp config create {CORE_CONFIG_SETTINGS}`
370+
When I run `wp config create --skip-check {CORE_CONFIG_SETTINGS}`
371371
Then STDOUT should contain:
372372
"""
373373
Success:
@@ -410,7 +410,9 @@ Feature: Bootstrap WP-CLI
410410
"""
411411
And the return code should be 0
412412

413-
@require-wp-4.0
413+
# `wp search-replace` does not yet support SQLite
414+
# See https://github.com/wp-cli/search-replace-command/issues/190
415+
@require-wp-4.0 @require-mysql
414416
Scenario: Run search-replace on ms_site_not_found
415417
Given a WP multisite installation
416418
And a wp-cli.yml file:

features/framework.feature

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ Feature: Load WP-CLI
8484
Error: This does not seem to be a WordPress installation.
8585
"""
8686

87+
# `wp db create` does not yet work on SQLite,
88+
# See https://github.com/wp-cli/db-command/issues/234
89+
@require-mysql
8790
Scenario: Globalize global variables in wp-config.php
8891
Given an empty directory
8992
And WP files
@@ -92,7 +95,7 @@ Feature: Load WP-CLI
9295
$redis_server = 'foo';
9396
"""
9497

95-
When I run `wp core config {CORE_CONFIG_SETTINGS} --extra-php < wp-config-extra.php`
98+
When I run `wp config create {CORE_CONFIG_SETTINGS} --skip-check --extra-php < wp-config-extra.php`
9699
Then the wp-config.php file should contain:
97100
"""
98101
$redis_server = 'foo';
@@ -179,6 +182,7 @@ Feature: Load WP-CLI
179182
https://example.com
180183
"""
181184
185+
@require-mysql
182186
Scenario: Handle error when WordPress cannot connect to the database host
183187
Given a WP installation
184188
And a invalid-host.php file:
@@ -265,6 +269,9 @@ Feature: Load WP-CLI
265269
https://example.com/
266270
"""
267271
272+
# `wp db reset` does not yet work on SQLite,
273+
# See https://github.com/wp-cli/db-command/issues/234
274+
@require-mysql
268275
Scenario: Show error message when site isn't found and there aren't additional prefixes.
269276
Given a WP installation
270277
And I run `wp db reset --yes`
@@ -309,7 +316,9 @@ Feature: Load WP-CLI
309316
"""
310317
And STDOUT should be empty
311318
312-
@require-wp-3.9
319+
# `wp db query` does not yet work on SQLite,
320+
# See https://github.com/wp-cli/db-command/issues/234
321+
@require-wp-3.9 @require-mysql
313322
Scenario: Display a more helpful error message when site can't be found
314323
Given a WP multisite installation
315324
And "define( 'DOMAIN_CURRENT_SITE', 'example.com' );" replaced with "define( 'DOMAIN_CURRENT_SITE', 'example.org' );" in the wp-config.php file

features/help.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ Feature: Get help about WP-CLI commands
155155
"""
156156
And STDERR should be empty
157157

158-
When I run `wp config create {CORE_CONFIG_SETTINGS}`
158+
When I run `wp config create {CORE_CONFIG_SETTINGS} --skip-check`
159159
And I run `wp help core install`
160160
Then STDOUT should contain:
161161
"""

features/hook.feature

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ Feature: Tests `WP_CLI::add_hook()`
2424
"""
2525
And the return code should be 0
2626

27+
# `wp db check` does not yet work on SQLite,
28+
# See https://github.com/wp-cli/db-command/issues/234
29+
@require-mysql
2730
Scenario: Add callback to the `before_invoke:db check`
2831
Given a WP installation
2932
And a before-invoke.php file:

features/requests.feature

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
Feature: Requests integration with both v1 and v2
22

3+
# This test downgrades to WordPress 5.8, but the SQLite plugin requires 6.0+
4+
@require-mysql
35
Scenario: Composer stack with Requests v1
46
Given an empty directory
57
And a composer.json file:
@@ -44,6 +46,8 @@ Feature: Requests integration with both v1 and v2
4446
"""
4547
And STDERR should be empty
4648

49+
# This test downgrades to WordPress 5.8, but the SQLite plugin requires 6.0+
50+
@require-mysql
4751
Scenario: Current version with WordPress-bundled Requests v1
4852
Given a WP installation
4953
And I run `wp core update --version=5.8 --force`
@@ -99,6 +103,8 @@ Feature: Requests integration with both v1 and v2
99103
Success: Installed 1 of 1 plugins.
100104
"""
101105

106+
# This test downgrades to WordPress 5.8, but the SQLite plugin requires 6.0+
107+
@require-mysql
102108
Scenario: Current version with WordPress-bundled Request v1 and an alias
103109
Given a WP installation in 'foo'
104110
And I run `wp --path=foo core download --version=5.8 --force`
@@ -116,4 +122,4 @@ Feature: Requests integration with both v1 and v2
116122
And STDERR should contain:
117123
"""
118124
Setting RequestsLibrary::$source to wp-core
119-
"""
125+
"""

features/utils-wp.feature

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ Feature: Utilities that depend on WordPress code
2121
1,,,
2222
"""
2323

24+
# `wp db query` does not yet work on SQLite,
25+
# See https://github.com/wp-cli/db-command/issues/234
26+
@require-mysql
2427
Scenario: Get WP table names for single site install
2528
Given a WP installation
2629
And I run `wp db query "CREATE TABLE xx_wp_posts ( id int );"`
@@ -330,6 +333,9 @@ Feature: Utilities that depend on WordPress code
330333
wp_posts
331334
"""
332335

336+
# `wp db query` does not yet work on SQLite,
337+
# See https://github.com/wp-cli/db-command/issues/234
338+
@require-mysql
333339
Scenario: Get WP table names for multisite install
334340
Given a WP multisite install
335341
And I run `wp db query "CREATE TABLE xx_wp_posts ( id int );"`

features/utils.feature

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Feature: Utilities that do NOT depend on WordPress code
22

3+
@require-mysql
34
Scenario Outline: Check that `proc_open()` and `proc_close()` aren't disabled for `Utils\run_mysql_command()`
45
When I try `{INVOKE_WP_CLI_WITH_PHP_ARGS--ddisable_functions=<func>} --skip-wordpress eval 'WP_CLI\Utils\run_mysql_command( null, array() );'`
56
Then STDERR should contain:
@@ -28,6 +29,7 @@ Feature: Utilities that do NOT depend on WordPress code
2829
| proc_open |
2930
| proc_close |
3031

32+
@require-mysql
3133
Scenario: Check that `Utils\run_mysql_command()` uses STDOUT and STDERR by default
3234
When I run `wp --skip-wordpress eval 'WP_CLI\Utils\run_mysql_command( "/usr/bin/env mysql --no-defaults", [ "user" => "{DB_USER}", "pass" => "{DB_PASSWORD}", "host" => "{DB_HOST}", "execute" => "SHOW DATABASES;" ] );'`
3335
Then STDOUT should contain:
@@ -47,6 +49,7 @@ Feature: Utilities that do NOT depend on WordPress code
4749
You have an error in your SQL syntax
4850
"""
4951

52+
@require-mysql
5053
Scenario: Check that `Utils\run_mysql_command()` can return data and errors if requested
5154
When I run `wp --skip-wordpress eval 'list( $stdout, $stderr, $exit_code ) = WP_CLI\Utils\run_mysql_command( "/usr/bin/env mysql --no-defaults", [ "user" => "{DB_USER}", "pass" => "{DB_PASSWORD}", "host" => "{DB_HOST}", "execute" => "SHOW DATABASES;" ], null, false ); fwrite( STDOUT, strtoupper( $stdout ) ); fwrite( STDERR, strtoupper( $stderr ) );'`
5255
Then STDOUT should not contain:
@@ -101,6 +104,7 @@ Feature: Utilities that do NOT depend on WordPress code
101104
When I run `{INVOKE_WP_CLI_WITH_PHP_ARGS--dsys_temp_dir=} --skip-wordpress eval 'echo WP_CLI\Utils\get_temp_dir();'`
102105
Then STDOUT should match /\/$/
103106

107+
@require-mysql
104108
Scenario: Ensure that Utils\run_mysql_command() passes through without reading full DB into memory
105109
Given a WP install
106110

php/utils-wp.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ function wp_not_installed() {
2323
}
2424
}
2525
if ( count( $found_prefixes ) ) {
26+
sort( $found_prefixes );
2627
$prefix_list = implode( ', ', $found_prefixes );
2728
$install_label = count( $found_prefixes ) > 1 ? 'installations' : 'installation';
2829
WP_CLI::error(

0 commit comments

Comments
 (0)