-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathcache-patch.feature
More file actions
126 lines (106 loc) · 3.38 KB
/
cache-patch.feature
File metadata and controls
126 lines (106 loc) · 3.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
Feature: Patch command available for the object cache
Scenario: Nested values from cache can be updated at any depth.
Given a WP install
And a wp-content/mu-plugins/test-harness.php file:
"""php
<?php
$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) [
'bar' => (object) [
'baz' => 2,
],
],
];
wp_cache_set( 'complex_key', $complex_key );
};
WP_CLI::add_hook( 'before_invoke:cache patch', $set_foo );
"""
When I run `wp cache patch insert my_key fuz baz`
Then STDOUT should be:
"""
Success: Updated cache key 'my_key'.
"""
When I run `wp cache patch insert complex_key foo bar fuz 34`
Then STDOUT should be:
"""
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:
"""
Success: Updated cache key 'my_key'.
"""
When I run `wp cache patch update other_key fuz biz`
Then STDOUT should be:
"""
Success: Value passed for cache key 'other_key' is unchanged.
"""
When I run `wp cache patch update complex_key foo bar baz 34`
Then STDOUT should be:
"""
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:
"""
Error: No data exists for key "foo"
"""
When I try `wp cache patch update my_key bar test`
Then STDERR should be:
"""
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:
"""
Error: No data exists for key "foo"
"""
When I try `wp cache patch delete my_key bar`
Then STDERR should be:
"""
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"
"""