|
| 1 | +Feature: Check if WordPress database update is needed |
| 2 | + |
| 3 | + # This test downgrades to an older WordPress version, but the SQLite plugin requires 6.0+ |
| 4 | + @require-mysql |
| 5 | + Scenario: Check if database update is needed on a single site |
| 6 | + Given a WP install |
| 7 | + And a disable_sidebar_check.php file: |
| 8 | + """ |
| 9 | + <?php |
| 10 | + WP_CLI::add_wp_hook( 'init', static function () { |
| 11 | + remove_action( 'after_switch_theme', '_wp_sidebars_changed' ); |
| 12 | + } ); |
| 13 | + """ |
| 14 | + And I try `wp theme install twentytwenty --activate` |
| 15 | + And I run `wp core download --version=5.4 --force` |
| 16 | + And I run `wp option update db_version 45805 --require=disable_sidebar_check.php` |
| 17 | + |
| 18 | + When I try `wp core check-update-db` |
| 19 | + Then the return code should be 1 |
| 20 | + And STDOUT should contain: |
| 21 | + """ |
| 22 | + WordPress database update required from db version 45805 to 47018. |
| 23 | + """ |
| 24 | + |
| 25 | + When I run `wp core update-db` |
| 26 | + Then STDOUT should contain: |
| 27 | + """ |
| 28 | + Success: WordPress database upgraded successfully from db version 45805 to 47018. |
| 29 | + """ |
| 30 | + |
| 31 | + When I run `wp core check-update-db` |
| 32 | + Then STDOUT should contain: |
| 33 | + """ |
| 34 | + Success: WordPress database is up to date. |
| 35 | + """ |
| 36 | + |
| 37 | + Scenario: Check if database update is needed when database is already up to date |
| 38 | + Given a WP install |
| 39 | + |
| 40 | + When I run `wp core check-update-db` |
| 41 | + Then STDOUT should contain: |
| 42 | + """ |
| 43 | + Success: WordPress database is up to date. |
| 44 | + """ |
| 45 | + |
| 46 | + Scenario: Check if database update is needed across network |
| 47 | + Given a WP multisite install |
| 48 | + And a disable_sidebar_check.php file: |
| 49 | + """ |
| 50 | + <?php |
| 51 | + WP_CLI::add_wp_hook( 'init', static function () { |
| 52 | + remove_action( 'after_switch_theme', '_wp_sidebars_changed' ); |
| 53 | + } ); |
| 54 | + """ |
| 55 | + And I try `wp theme install twentytwenty --activate` |
| 56 | + And I run `wp core download --version=6.6 --force` |
| 57 | + And I run `wp option update db_version 57155 --require=disable_sidebar_check.php` |
| 58 | + And I run `wp site option update wpmu_upgrade_site 57155` |
| 59 | + And I run `wp site create --slug=foo` |
| 60 | + And I run `wp site create --slug=bar` |
| 61 | + And I run `wp site create --slug=burrito --porcelain` |
| 62 | + And save STDOUT as {BURRITO_ID} |
| 63 | + And I run `wp site create --slug=taco --porcelain` |
| 64 | + And save STDOUT as {TACO_ID} |
| 65 | + And I run `wp site create --slug=pizza --porcelain` |
| 66 | + And save STDOUT as {PIZZA_ID} |
| 67 | + And I run `wp site archive {BURRITO_ID}` |
| 68 | + And I run `wp site spam {TACO_ID}` |
| 69 | + And I run `wp site delete {PIZZA_ID} --yes` |
| 70 | + And I run `wp core update` |
| 71 | + |
| 72 | + When I try `wp core check-update-db --network` |
| 73 | + Then the return code should be 1 |
| 74 | + And STDOUT should contain: |
| 75 | + """ |
| 76 | + WordPress database update needed on 3/3 sites: |
| 77 | + """ |
| 78 | + |
| 79 | + When I run `wp core update-db --network` |
| 80 | + Then STDOUT should contain: |
| 81 | + """ |
| 82 | + Success: WordPress database upgraded on 3/3 sites. |
| 83 | + """ |
| 84 | + |
| 85 | + When I run `wp core check-update-db --network` |
| 86 | + Then STDOUT should contain: |
| 87 | + """ |
| 88 | + Success: WordPress databases are up to date on 3/3 sites. |
| 89 | + """ |
| 90 | + |
| 91 | + Scenario: Check database update on network installation errors on single site |
| 92 | + Given a WP install |
| 93 | + |
| 94 | + When I try `wp core check-update-db --network` |
| 95 | + Then STDERR should contain: |
| 96 | + """ |
| 97 | + Error: This is not a multisite installation. |
| 98 | + """ |
| 99 | + And the return code should be 1 |
0 commit comments