Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add tests covering additional pluch/patch arguments
  • Loading branch information
petitphp committed May 15, 2025
commit a3c3782cb6ec054fe01ab5555a89615a4934fd6a
37 changes: 37 additions & 0 deletions features/cache-patch.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Feature: Patch command available for the object cache
$set_foo = function(){
wp_cache_set( 'my_key', ['foo' => 'bar'] );
wp_cache_set( 'other_key', ['fuz' => 'biz'] );
wp_cache_set( 'my_key_in_group', ['fuz' => 'biz'], 'my_group' );

$complex_key = (object) [
'foo' => (object) [
Expand All @@ -34,12 +35,24 @@ Feature: Patch command available for the object cache
Success: Updated cache key 'complex_key'.
"""

When I try `wp cache patch insert my_key_in_group foo bar --group=my_group`
Then STDOUT should be:
"""
Success: Updated cache key 'my_key_in_group'.
"""

When I try `wp cache patch insert unknown_key foo bar`
Then STDERR should be:
"""
Error: Cannot create key "foo" on data type boolean
"""

When I try `wp cache patch insert other_key foo bar --group=unknown_group`
Then STDERR should be:
"""
Error: Cannot create key "foo" on data type boolean
"""

When I run `wp cache patch update my_key foo test`
Then STDOUT should be:
"""
Expand All @@ -58,6 +71,12 @@ Feature: Patch command available for the object cache
Success: Updated cache key 'complex_key'.
"""

When I try `wp cache patch update my_key_in_group fuz baz --group=my_group`
Then STDOUT should be:
"""
Success: Updated cache key 'my_key_in_group'.
"""

When I try `wp cache patch update unknown_key foo test`
Then STDERR should be:
"""
Expand All @@ -70,12 +89,24 @@ Feature: Patch command available for the object cache
Error: No data exists for key "bar"
"""

When I try `wp cache patch update my_key foo baz --expiration=60`
Then STDOUT should be:
"""
Success: Updated cache key 'my_key'.
"""

When I run `wp cache patch delete my_key foo`
Then STDOUT should be:
"""
Success: Updated cache key 'my_key'.
"""

When I try `wp cache patch delete my_key_in_group fuz --group=my_group`
Then STDOUT should be:
"""
Success: Updated cache key 'my_key_in_group'.
"""

When I try `wp cache patch delete unknown_key foo`
Then STDERR should be:
"""
Expand All @@ -87,3 +118,9 @@ Feature: Patch command available for the object cache
"""
Error: No data exists for key "bar"
"""

When I try `wp cache patch delete my_key foo --group=my_group`
Then STDERR should be:
"""
Error: No data exists for key "foo"
"""
12 changes: 12 additions & 0 deletions features/cache-pluck.feature
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ Feature: Pluck command available for the object cache
baz
"""

When I run `wp cache pluck my_key_2 foo bar --format=json`
Then STDOUT should be:
"""
"baz"
"""

When I run `wp cache pluck my_key_2 foo --format=json`
Then STDOUT should be:
"""
{"bar":"baz"}
"""

When I run `wp cache pluck my_key_3 foo --group=my_custom_group`
Then STDOUT should be:
"""
Expand Down
12 changes: 12 additions & 0 deletions features/transient-patch.feature
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ Feature: Patch command available for the transient cache
{"foo":{"bar":"baz","fuz":"biz"}}
"""

When I run `wp transient patch insert my_key fiz bar --expiration=300`
Then STDOUT should be:
"""
Success: Updated transient 'my_key'.
"""

When I run `wp transient get my_key --format=json`
Then STDOUT should be:
"""
{"foo":"bar","fuz":"baz","fiz":"bar"}
"""

When I try `wp transient patch insert unknown_key foo bar`
Then STDERR should be:
"""
Expand Down
12 changes: 12 additions & 0 deletions features/transient-pluck.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ Feature: Pluck command available for the transient cache
baz
"""

When I run `wp transient pluck my_key_2 foo bar --format=json`
Then STDOUT should be:
"""
"baz"
"""

When I run `wp transient pluck my_key_2 foo --format=json`
Then STDOUT should be:
"""
{"bar":"baz"}
"""

When I try `wp transient pluck unknown_key foo`
Then STDERR should be:
"""
Expand Down