Skip to content

Commit ab5d73b

Browse files
committed
Add more tests for deleting (expired) transients
1 parent cfebf3a commit ab5d73b

File tree

1 file changed

+125
-0
lines changed

1 file changed

+125
-0
lines changed

features/transient.feature

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ Feature: Manage WordPress transient cache
5555
Success: Transient deleted.
5656
"""
5757

58+
When I run `wp transient set foo bar --network`
59+
And I run `wp transient set foo2 bar2 --network`
60+
And I run `wp transient delete --all`
61+
Then STDOUT should contain:
62+
"""
63+
transients deleted from the database.
64+
"""
65+
5866
Scenario: Transient delete and other flags
5967
Given a WP install
6068

@@ -66,6 +74,7 @@ Feature: Manage WordPress transient cache
6674

6775
When I run `wp transient set foo bar`
6876
And I run `wp transient set foo2 bar2`
77+
And I run `wp transient set foo3 bar3 --network`
6978
And I run `wp transient delete --all`
7079
Then STDOUT should contain:
7180
"""
@@ -83,3 +92,119 @@ Feature: Manage WordPress transient cache
8392
"""
8493
Warning: Transient with key "foo2" is not set.
8594
"""
95+
96+
When I try `wp transient get foo3 --network`
97+
Then STDERR should be:
98+
"""
99+
Warning: Transient with key "foo3" is not set.
100+
"""
101+
102+
When I run `wp transient set foo bar 60`
103+
Then STDOUT should be:
104+
"""
105+
Success: Transient added.
106+
"""
107+
108+
# Change timeout to be in the past.
109+
When I run `wp option update _transient_timeout_foo 1321009871`
110+
And I run `wp transient delete --expired`
111+
Then STDOUT should contain:
112+
"""
113+
transient deleted from the database.
114+
"""
115+
116+
When I try `wp transient get foo`
117+
Then STDERR should be:
118+
"""
119+
Warning: Transient with key "foo" is not set.
120+
"""
121+
122+
When I run `wp transient set foo bar 60 --network`
123+
Then STDOUT should be:
124+
"""
125+
Success: Transient added.
126+
"""
127+
128+
# Change timeout to be in the past.
129+
When I run `wp option update _site_transient_timeout_foo 1321009871`
130+
And I run `wp transient delete --expired`
131+
Then STDOUT should contain:
132+
"""
133+
transient deleted from the database.
134+
"""
135+
136+
When I try `wp transient get foo --network`
137+
Then STDERR should be:
138+
"""
139+
Warning: Transient with key "foo" is not set.
140+
"""
141+
142+
Scenario: Network transient delete and other flags
143+
Given a WP multisite install
144+
145+
When I run `wp transient set foo bar`
146+
And I run `wp transient set foo2 bar2`
147+
And I run `wp transient set foo3 bar3 --network`
148+
And I run `wp transient delete --all`
149+
Then STDOUT should contain:
150+
"""
151+
transients deleted from the database.
152+
"""
153+
154+
When I try `wp transient get foo`
155+
Then STDERR should be:
156+
"""
157+
Warning: Transient with key "foo" is not set.
158+
"""
159+
160+
When I try `wp transient get foo2`
161+
Then STDERR should be:
162+
"""
163+
Warning: Transient with key "foo2" is not set.
164+
"""
165+
166+
When I try `wp transient get foo3 --network`
167+
Then STDERR should be:
168+
"""
169+
Warning: Transient with key "foo3" is not set.
170+
"""
171+
172+
When I run `wp transient set foo bar 60`
173+
Then STDOUT should be:
174+
"""
175+
Success: Transient added.
176+
"""
177+
178+
# Change timeout to be in the past.
179+
When I run `wp option update _transient_timeout_foo 1321009871`
180+
And I run `wp transient delete --expired`
181+
Then STDOUT should contain:
182+
"""
183+
transient deleted from the database.
184+
"""
185+
186+
When I try `wp transient get foo`
187+
Then STDERR should be:
188+
"""
189+
Warning: Transient with key "foo" is not set.
190+
"""
191+
192+
When I run `wp transient set foo bar 60 --network`
193+
Then STDOUT should be:
194+
"""
195+
Success: Transient added.
196+
"""
197+
198+
# Change timeout to be in the past.
199+
When I run `wp site option update _site_transient_timeout_foo 1321009871`
200+
And I run `wp transient delete --expired`
201+
Then STDOUT should contain:
202+
"""
203+
transient deleted from the database.
204+
"""
205+
206+
When I try `wp transient get foo --network`
207+
Then STDERR should be:
208+
"""
209+
Warning: Transient with key "foo" is not set.
210+
"""

0 commit comments

Comments
 (0)