-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restore
Site_Option_Command
and User_Session_Command
These commands need to be included in this repo because of registry race conditions
- Loading branch information
1 parent
48d0f0c
commit 06037f3
Showing
6 changed files
with
685 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
Feature: Manage WordPress site options | ||
|
||
Scenario: Site Option CRUD | ||
Given a WP multisite install | ||
|
||
# String values | ||
When I run `wp site option add str_opt 'bar'` | ||
Then STDOUT should not be empty | ||
|
||
When I run `wp site option get str_opt` | ||
Then STDOUT should be: | ||
""" | ||
bar | ||
""" | ||
|
||
When I run `wp site option list` | ||
Then STDOUT should not be empty | ||
|
||
When I run `wp site option list` | ||
Then STDOUT should contain: | ||
""" | ||
str_opt bar | ||
""" | ||
|
||
When I run `wp site option list --search='str_o*'` | ||
Then STDOUT should be a table containing rows: | ||
| meta_key | meta_value | | ||
| str_opt | bar | | ||
|
||
When I run `wp site option list --search='str_o*' --format=total_bytes` | ||
Then STDOUT should be: | ||
""" | ||
3 | ||
""" | ||
|
||
When I run `wp site option list` | ||
Then STDOUT should contain: | ||
""" | ||
admin_user_id 1 | ||
""" | ||
|
||
When I run `wp site option delete str_opt` | ||
Then STDOUT should not be empty | ||
|
||
When I run `wp site option list` | ||
Then STDOUT should not contain: | ||
""" | ||
str_opt bar | ||
""" | ||
|
||
When I try `wp site option get str_opt` | ||
Then the return code should be 1 | ||
|
||
# Integer values | ||
When I run `wp site option update admin_user_id 2` | ||
Then STDOUT should not be empty | ||
|
||
When I run `wp site option get admin_user_id` | ||
Then STDOUT should be: | ||
""" | ||
2 | ||
""" | ||
|
||
When I run `wp site option update admin_user_id 1` | ||
Then STDOUT should contain: | ||
""" | ||
Success: Updated 'admin_user_id' site option. | ||
""" | ||
|
||
When I run the previous command again | ||
Then STDOUT should contain: | ||
""" | ||
Success: Value passed for 'admin_user_id' site option is unchanged. | ||
""" | ||
|
||
When I run `wp site option get admin_user_id` | ||
Then STDOUT should be: | ||
""" | ||
1 | ||
""" | ||
|
||
# JSON values | ||
When I run `wp site option set json_opt '[ 1, 2 ]' --format=json` | ||
Then STDOUT should not be empty | ||
|
||
When I run the previous command again | ||
Then STDOUT should not be empty | ||
|
||
When I run `wp site option get json_opt --format=json` | ||
Then STDOUT should be: | ||
""" | ||
[1,2] | ||
""" | ||
|
||
# Reading from files | ||
Given a value.json file: | ||
""" | ||
{ | ||
"foo": "bar", | ||
"list": [1, 2, 3] | ||
} | ||
""" | ||
When I run `wp site option set foo --format=json < value.json` | ||
And I run `wp site option get foo --format=json` | ||
Then STDOUT should be JSON containing: | ||
""" | ||
{ | ||
"foo": "bar", | ||
"list": [1, 2, 3] | ||
} | ||
""" | ||
Scenario: Error on single install | ||
Given a WP install | ||
When I try `wp site option get str_opt` | ||
Then STDERR should be: | ||
""" | ||
Error: This is not a multisite install. | ||
""" | ||
When I try `wp site option add str_opt 'bar'` | ||
Then STDERR should be: | ||
""" | ||
Error: This is not a multisite install. | ||
""" | ||
Scenario: Filter options by `--site_id` | ||
Given a WP multisite install | ||
When I run `wp db query "INSERT INTO wp_sitemeta (site_id,meta_key,meta_value) VALUES (2,'wp_cli_test_option','foobar');"` | ||
Then the return code should be 0 | ||
When I run `wp site option list` | ||
Then STDOUT should contain: | ||
""" | ||
wp_cli_test_option | ||
""" | ||
And STDERR should be empty | ||
When I run `wp site option list --site_id=1` | ||
Then STDOUT should not contain: | ||
""" | ||
wp_cli_test_option | ||
""" | ||
And STDERR should be empty | ||
When I run `wp site option list --site_id=2` | ||
Then STDOUT should contain: | ||
""" | ||
wp_cli_test_option | ||
""" | ||
And STDERR should be empty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
Feature: Manage user session | ||
|
||
Background: | ||
Given a WP install | ||
|
||
@require-wp-4.0 | ||
Scenario: Destroy user sessions | ||
When I run `wp eval 'wp_set_current_user(1);'` | ||
And I run `wp eval 'wp_set_auth_cookie(1);'` | ||
And I run `wp eval 'wp_set_current_user(1);'` | ||
And I run `wp eval 'wp_set_auth_cookie(1);'` | ||
And I run `wp user session list admin --format=count` | ||
Then STDOUT should be: | ||
""" | ||
2 | ||
""" | ||
|
||
When I run `wp user session destroy admin` | ||
Then STDOUT should be: | ||
""" | ||
Success: Destroyed session. 1 remaining. | ||
""" | ||
|
||
When I run `wp user session list admin --format=count` | ||
Then STDOUT should be: | ||
""" | ||
1 | ||
""" | ||
|
||
When I run `wp user session destroy admin --all` | ||
Then STDOUT should be: | ||
""" | ||
Success: Destroyed all sessions. | ||
""" | ||
|
||
And I run `wp user session list admin --format=count` | ||
Then STDOUT should be: | ||
""" | ||
0 | ||
""" |
Oops, something went wrong.