|
1 | 1 | Feature: List WordPress themes |
2 | 2 |
|
3 | | - Background: |
| 3 | + Scenario: Refresh update_themes transient when listing themes with --force-check flag |
4 | 4 | Given a WP install |
5 | | - And a setup.php file: |
| 5 | + And I run `wp theme delete --all --force` |
| 6 | + And I run `wp theme install --force twentytwentyfour --version=1.1` |
| 7 | + And a update-transient.php file: |
6 | 8 | """ |
7 | 9 | <?php |
8 | | - $theme_transient = new stdClass; |
9 | | - $theme_transient->last_checked = time(); |
10 | | - $theme_transient->checked = []; |
11 | | - $theme_transient->response = []; |
12 | | - $theme_transient->no_update = []; |
13 | | - $theme_transient->translations = []; |
14 | | - $return = update_option( '_site_transient_update_themes', $theme_transient ); |
| 10 | + $transient = get_site_transient( 'update_themes' ); |
| 11 | + $transient->response['twentytwentyfour'] = (object) array( |
| 12 | + 'theme' => 'twentytwentyfour', |
| 13 | + 'new_version' => '100.0.0', |
| 14 | + 'url' => 'https://wordpress.org/themes/twentytwentyfour/', |
| 15 | + 'package' => 'https://downloads.wordpress.org/theme/twentytwentyfour.100.zip', |
| 16 | + 'requires' => '6.4', |
| 17 | + 'requires_php' => '7.0' |
| 18 | + ); |
| 19 | + $transient->checked = array( |
| 20 | + 'twentytwentyfour' => '1.1', |
| 21 | + ); |
| 22 | + unset( $transient->no_update['twentytwentyfour'] ); |
| 23 | + set_site_transient( 'update_themes', $transient ); |
| 24 | + WP_CLI::success( 'Transient updated.' ); |
15 | 25 | """ |
16 | | - And I run `wp transient delete update_themes --network` |
17 | 26 |
|
18 | | - Scenario: Refresh update_themes transient when listing themes with --force-check flag |
| 27 | + # Populates the initial transient in the database |
| 28 | + When I run `wp theme list --fields=name,status,update` |
| 29 | + Then STDOUT should be a table containing rows: |
| 30 | + | name | status | update | |
| 31 | + | twentytwentyfour | active | none | |
| 32 | + |
| 33 | + # Modify the transient in the database to simulate an update |
| 34 | + When I run `wp eval-file update-transient.php` |
| 35 | + Then STDOUT should be: |
| 36 | + """ |
| 37 | + Success: Transient updated. |
| 38 | + """ |
| 39 | + |
| 40 | + # Verify the fake transient value produces the expected output |
| 41 | + When I run `wp theme list --fields=name,status,update` |
| 42 | + Then STDOUT should be a table containing rows: |
| 43 | + | name | status | update | |
| 44 | + | twentytwentyfour | active | available | |
19 | 45 |
|
20 | | - # Listing the themes will populate the transient in the database |
21 | | - When I run `wp theme list` |
22 | | - Then STDOUT should not be empty |
| 46 | + # Repeating the same command again should produce the same results |
| 47 | + When I run `wp theme list --fields=name,status,update` |
| 48 | + Then STDOUT should be a table containing rows: |
| 49 | + | name | status | update | |
| 50 | + | twentytwentyfour | active | available | |
23 | 51 |
|
24 | | - When I run `wp transient set update_themes test_value --network` |
25 | | - And I run `wp theme list --force-check` |
| 52 | + # Using the --force-check flag should refresh the transient back to the original value |
| 53 | + When I run `wp theme list --fields=name,status,update --force-check` |
| 54 | + Then STDOUT should be a table containing rows: |
| 55 | + | name | status | update | |
| 56 | + | twentytwentyfour | active | none | |
26 | 57 |
|
27 | | - Then STDOUT should be empty |
| 58 | + When I try `wp theme list --skip-update-check --force-check` |
| 59 | + Then STDERR should contain: |
| 60 | + """ |
| 61 | + Error: theme updates cannot be both force-checked and skipped. Choose one. |
| 62 | + """ |
| 63 | + And STDOUT should be empty |
| 64 | + And the return code should be 1 |
0 commit comments