File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed
Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -269,3 +269,33 @@ Feature: Option commands have pluck and patch.
269269 """
270270 [ "new", "bar" ]
271271 """
272+
273+ @patch @pluck
274+ Scenario: An object value can be updated
275+ Given a WP install
276+ And a setup.php file:
277+ """
278+ <?php
279+ $option = new stdClass;
280+ $option-> test_mode = 0;
281+ $ret = update_option( 'wp_cli_test' , $option );
282+ """
283+ And I run `wp eval-file setup.php`
284+
285+ When I run `wp option pluck wp_cli_test test_mode`
286+ Then STDOUT should be:
287+ """
288+ 0
289+ """
290+
291+ When I run `wp option patch update wp_cli_test test_mode 1`
292+ Then STDOUT should be:
293+ """
294+ Success: Updated 'wp_cli_test' option.
295+ """
296+
297+ When I run `wp option pluck wp_cli_test test_mode`
298+ Then STDOUT should be:
299+ """
300+ 1
301+ """
Original file line number Diff line number Diff line change @@ -86,6 +86,19 @@ function it_can_set_a_nested_object_value() {
8686 $ this ->assertEquals ( 'new ' , $ object ->foo ->bar );
8787 }
8888
89+ /** @test */
90+ function it_can_update_an_integer_object_value () {
91+ $ object = (object ) array (
92+ 'test_mode ' => 0 ,
93+ );
94+ $ this ->assertEquals ( 0 , $ object ->test_mode );
95+
96+ $ traverser = new RecursiveDataStructureTraverser ( $ object );
97+ $ traverser ->update ( array ( 'test_mode ' ), 1 );
98+
99+ $ this ->assertEquals ( 1 , $ object ->test_mode );
100+ }
101+
89102 /** @test */
90103 function it_can_delete_a_nested_array_value () {
91104 $ array = array (
You can’t perform that action at this time.
0 commit comments