@@ -55,7 +55,7 @@ Feature: Manage WordPress transient cache
5555 Success: Transient deleted.
5656 """
5757
58- Scenario : Transient delete and other flags
58+ Scenario : Deleting all transients on single site
5959 Given a WP install
6060
6161 When I try `wp transient delete`
@@ -65,11 +65,13 @@ Feature: Manage WordPress transient cache
6565 """
6666
6767 When I run `wp transient set foo bar`
68- And I run `wp transient set foo2 bar2`
68+ And I run `wp transient set foo2 bar2 600`
69+ And I run `wp transient set foo3 bar3 --network`
70+ And I run `wp transient set foo4 bar4 600 --network`
6971 And I run `wp transient delete --all`
70- Then STDOUT should contain :
72+ Then STDOUT should be :
7173 """
72- transients deleted from the database.
74+ Success: 2 transients deleted from the database.
7375 """
7476
7577 When I try `wp transient get foo`
@@ -83,3 +85,292 @@ Feature: Manage WordPress transient cache
8385 """
8486 Warning: Transient with key "foo2" is not set.
8587 """
88+
89+ When I run `wp transient get foo3 --network`
90+ Then STDOUT should be:
91+ """
92+ bar3
93+ """
94+
95+ When I run `wp transient get foo4 --network`
96+ Then STDOUT should be:
97+ """
98+ bar4
99+ """
100+
101+ When I run `wp transient delete --all --network`
102+ Then STDOUT should be:
103+ """
104+ Success: 2 transients deleted from the database.
105+ """
106+
107+ When I try `wp transient get foo3 --network`
108+ Then STDERR should be:
109+ """
110+ Warning: Transient with key "foo3" is not set.
111+ """
112+
113+ When I try `wp transient get foo4 --network`
114+ Then STDERR should be:
115+ """
116+ Warning: Transient with key "foo4" is not set.
117+ """
118+
119+ Scenario : Deleting expired transients on single site
120+ Given a WP install
121+ And I run `wp transient set foo bar 60`
122+ And I run `wp transient set foo2 bar2 60`
123+ And I run `wp transient set foo3 bar3 60 --network`
124+ And I run `wp transient set foo4 bar4 60 --network`
125+ # Change timeout to be in the past.
126+ And I run `wp option update _transient_timeout_foo 1321009871`
127+ And I run `wp option update _site_transient_timeout_foo3 1321009871`
128+
129+ When I run `wp transient delete --expired`
130+ Then STDOUT should be:
131+ """
132+ Success: 1 expired transient deleted from the database.
133+ """
134+
135+ When I try `wp transient get foo`
136+ Then STDERR should be:
137+ """
138+ Warning: Transient with key "foo" is not set.
139+ """
140+
141+ When I run `wp transient get foo2`
142+ Then STDOUT should be:
143+ """
144+ bar2
145+ """
146+
147+ # Check if option still exists as a get transient call will remove it.
148+ When I run `wp option get _site_transient_foo3`
149+ Then STDOUT should be:
150+ """
151+ bar3
152+ """
153+
154+ When I run `wp transient get foo4 --network`
155+ Then STDOUT should be:
156+ """
157+ bar4
158+ """
159+
160+ When I run `wp transient delete --expired --network`
161+ Then STDOUT should be:
162+ """
163+ Success: 1 expired transient deleted from the database.
164+ """
165+
166+ When I try `wp transient get foo`
167+ Then STDERR should be:
168+ """
169+ Warning: Transient with key "foo" is not set.
170+ """
171+
172+ When I run `wp transient get foo2`
173+ Then STDOUT should be:
174+ """
175+ bar2
176+ """
177+
178+ When I try `wp transient get foo3 --network`
179+ Then STDERR should be:
180+ """
181+ Warning: Transient with key "foo3" is not set.
182+ """
183+
184+ When I run `wp transient get foo4 --network`
185+ Then STDOUT should be:
186+ """
187+ bar4
188+ """
189+
190+ Scenario : Deleting all transients on multisite
191+ Given a WP multisite install
192+ And I run `wp site create --slug=foo`
193+
194+ When I try `wp transient delete`
195+ Then STDERR should be:
196+ """
197+ Error: Please specify transient key, or use --all or --expired.
198+ """
199+
200+ When I run `wp transient set foo bar`
201+ And I run `wp transient set foo2 bar2 600`
202+ And I run `wp transient set foo3 bar3 --network`
203+ And I run `wp transient set foo4 bar4 600 --network`
204+ And I run `wp --url=example.com/foo transient set foo5 bar5 --network`
205+ And I run `wp --url=example.com/foo transient set foo6 bar6 600 --network`
206+ And I run `wp transient delete --all`
207+ Then STDOUT should be:
208+ """
209+ Success: 2 transients deleted from the database.
210+ """
211+
212+ When I try `wp transient get foo`
213+ Then STDERR should be:
214+ """
215+ Warning: Transient with key "foo" is not set.
216+ """
217+
218+ When I try `wp transient get foo2`
219+ Then STDERR should be:
220+ """
221+ Warning: Transient with key "foo2" is not set.
222+ """
223+
224+ When I run `wp transient get foo3 --network`
225+ Then STDOUT should be:
226+ """
227+ bar3
228+ """
229+
230+ When I run `wp transient get foo4 --network`
231+ Then STDOUT should be:
232+ """
233+ bar4
234+ """
235+
236+ When I run `wp --url=example.com/foo transient get foo5 --network`
237+ Then STDOUT should be:
238+ """
239+ bar5
240+ """
241+
242+ When I run `wp --url=example.com/foo transient get foo6 --network`
243+ Then STDOUT should be:
244+ """
245+ bar6
246+ """
247+
248+ When I run `wp transient delete --all --network`
249+ Then STDOUT should be:
250+ """
251+ Success: 4 transients deleted from the database.
252+ """
253+
254+ When I try `wp transient get foo3 --network`
255+ Then STDERR should be:
256+ """
257+ Warning: Transient with key "foo3" is not set.
258+ """
259+
260+ When I try `wp transient get foo4 --network`
261+ Then STDERR should be:
262+ """
263+ Warning: Transient with key "foo4" is not set.
264+ """
265+
266+ When I try `wp --url=example.com/foo transient get foo5 --network`
267+ Then STDERR should be:
268+ """
269+ Warning: Transient with key "foo5" is not set.
270+ """
271+
272+ When I try `wp --url=example.com/foo transient get foo6 --network`
273+ Then STDERR should be:
274+ """
275+ Warning: Transient with key "foo6" is not set.
276+ """
277+
278+ Scenario : Deleting expired transients on multisite
279+ Given a WP multisite install
280+ And I run `wp site create --slug=foo`
281+ And I run `wp transient set foo bar 60`
282+ And I run `wp transient set foo2 bar2 60`
283+ And I run `wp transient set foo3 bar3 60 --network`
284+ And I run `wp transient set foo4 bar4 60 --network`
285+ And I run `wp --url=example.com/foo transient set foo5 bar5 60 --network`
286+ And I run `wp --url=example.com/foo transient set foo6 bar6 60 --network`
287+ # Change timeout to be in the past.
288+ And I run `wp option update _transient_timeout_foo 1321009871`
289+ And I run `wp site option update _site_transient_timeout_foo3 1321009871`
290+ And I run `wp --url=example.com/foo site option update _site_transient_timeout_foo5 1321009871`
291+
292+ When I run `wp transient delete --expired`
293+ Then STDOUT should be:
294+ """
295+ Success: 1 expired transient deleted from the database.
296+ """
297+
298+ When I try `wp transient get foo`
299+ Then STDERR should be:
300+ """
301+ Warning: Transient with key "foo" is not set.
302+ """
303+
304+ When I run `wp transient get foo2`
305+ Then STDOUT should be:
306+ """
307+ bar2
308+ """
309+
310+ # Check if option still exists as a get transient call will remove it.
311+ When I run `wp site option get _site_transient_foo3`
312+ Then STDOUT should be:
313+ """
314+ bar3
315+ """
316+
317+ When I run `wp transient get foo4 --network`
318+ Then STDOUT should be:
319+ """
320+ bar4
321+ """
322+
323+ # Check if option still exists as a get transient call will remove it.
324+ When I run `wp --url=example.com/foo site option get _site_transient_foo5`
325+ Then STDOUT should be:
326+ """
327+ bar5
328+ """
329+
330+ When I run `wp --url=example.com/foo transient get foo6 --network`
331+ Then STDOUT should be:
332+ """
333+ bar6
334+ """
335+
336+ When I run `wp transient delete --expired --network`
337+ Then STDOUT should be:
338+ """
339+ Success: 2 expired transients deleted from the database.
340+ """
341+
342+ When I try `wp transient get foo`
343+ Then STDERR should be:
344+ """
345+ Warning: Transient with key "foo" is not set.
346+ """
347+
348+ When I run `wp transient get foo2`
349+ Then STDOUT should be:
350+ """
351+ bar2
352+ """
353+
354+ When I try `wp transient get foo3 --network`
355+ Then STDERR should be:
356+ """
357+ Warning: Transient with key "foo3" is not set.
358+ """
359+
360+ When I run `wp transient get foo4 --network`
361+ Then STDOUT should be:
362+ """
363+ bar4
364+ """
365+
366+ When I try `wp --url=example.com/foo transient get foo5 --network`
367+ Then STDERR should be:
368+ """
369+ Warning: Transient with key "foo5" is not set.
370+ """
371+
372+ When I run `wp --url=example.com/foo transient get foo6 --network`
373+ Then STDOUT should be:
374+ """
375+ bar6
376+ """
0 commit comments