Skip to content

Commit e9c2d29

Browse files
committed
Add acceptance tests for theme mod value-type formatting
Cover booleans and empty arrays across the output formats: the table format renders them as readable placeholders, while json and csv keep the native types.
1 parent c8fb939 commit e9c2d29

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

‎features/theme-mod.feature‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,34 @@ Feature: Manage WordPress theme mods
114114
value: null
115115
"""
116116

117+
Scenario: Getting theme mods keeps native value types for machine-readable formats
118+
Given a WP install
119+
120+
When I run `wp eval 'set_theme_mod( "flag_off", false ); set_theme_mod( "flag_on", true ); set_theme_mod( "empty_thing", [] ); set_theme_mod( "nested", [ "child" => "x" ] );'`
121+
122+
# The table format is for humans, so types are shown as readable placeholders.
123+
And I run `wp theme mod get --all`
124+
Then STDOUT should be a table containing rows:
125+
| key | value |
126+
| flag_off | [false] |
127+
| flag_on | [true] |
128+
| empty_thing | [empty array] |
129+
130+
# Machine-readable formats keep the native value types.
131+
When I run `wp theme mod get --all --format=json`
132+
Then STDOUT should be JSON containing:
133+
"""
134+
[{"key":"flag_off","value":false},{"key":"flag_on","value":true},{"key":"empty_thing","value":[]},{"key":"nested","value":""},{"key":"nested.child","value":"x"}]
135+
"""
136+
137+
When I run `wp theme mod get --all --format=csv`
138+
Then STDOUT should be CSV containing:
139+
| key | value |
140+
| flag_off | false |
141+
| flag_on | true |
142+
| empty_thing | [] |
143+
| nested.child | x |
144+
117145
Scenario: Setting theme mods
118146
Given a WP install
119147

0 commit comments

Comments
 (0)