-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathcache-pluck.feature
More file actions
52 lines (43 loc) · 1.27 KB
/
cache-pluck.feature
File metadata and controls
52 lines (43 loc) · 1.27 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
Feature: Pluck command available for the object cache
Scenario: Nested values from cache can be retrieved 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( 'my_key_2', ['foo' => ['bar' => 'baz']] );
wp_cache_set( 'my_key_3', ['foo' => 'bar_custom'], 'my_custom_group' );
};
WP_CLI::add_hook( 'before_invoke:cache pluck', $set_foo );
"""
When I run `wp cache pluck my_key foo`
Then STDOUT should be:
"""
bar
"""
When I run `wp cache pluck my_key_2 foo bar`
Then STDOUT should be:
"""
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:
"""
bar_custom
"""
When I try `wp cache pluck unknown_key test`
Then STDERR should be:
"""
Warning: No object found for the key 'unknown_key' in group 'default'
"""