Skip to content

Commit b49eb56

Browse files
committed
improve tests for --regex-limit
1 parent 5b33953 commit b49eb56

File tree

1 file changed

+21
-31
lines changed

1 file changed

+21
-31
lines changed

features/search-replace.feature

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -177,16 +177,6 @@ Feature: Do global search/replace
177177
"""
178178
world, Hello
179179
"""
180-
When I run `wp search-replace 'o' 'O' --regex --regex-limit=1`
181-
Then STDOUT should contain:
182-
"""
183-
wp_posts
184-
"""
185-
When I run `wp post list --fields=post_title`
186-
Then STDOUT should contain:
187-
"""
188-
wOrld, Hello
189-
"""
190180

191181
Scenario: Regex search/replace with a incorrect `--regex-flags`
192182
Given a WP install
@@ -200,16 +190,6 @@ Feature: Do global search/replace
200190
kppr
201191
"""
202192
And the return code should be 1
203-
When I run `wp search-replace 'o' 'O' --regex --regex-limit=1`
204-
Then STDOUT should contain:
205-
"""
206-
wp_posts
207-
"""
208-
When I run `wp post list --fields=post_title`
209-
Then STDOUT should contain:
210-
"""
211-
HellO world!
212-
"""
213193

214194
Scenario: Search and replace within theme mods
215195
Given a WP install
@@ -900,17 +880,6 @@ Feature: Do global search/replace
900880
Content_ab\1z__baz_1234567890_eb\1z__bez_1234567890_ib\1z__biz_1234567890_ob\1z__boz_1234567890_ub\1z__buz_
901881
"""
902882

903-
When I run `wp search-replace '_{2}' '-' wp_posts --regex --regex-limit=2 --log --before_context=11 --after_context=11`
904-
Then STDOUT should contain:
905-
"""
906-
Title_ab\1z-baz-ob\1z__boz_
907-
"""
908-
When I run `wp post get {POST_ID} --field=title`
909-
Then STDOUT should be:
910-
"""
911-
Title_ab\1z-baz-ob\1z__boz_
912-
"""
913-
914883
Scenario: Logging with prefixes and custom colors
915884
Given a WP install
916885

@@ -1061,3 +1030,24 @@ Feature: Do global search/replace
10611030
"""
10621031
Success: 1 replacement to be made.
10631032
"""
1033+
1034+
Scenario: Regex search/replace with `--regex-limit=1` option
1035+
Given a WP install
1036+
And I run `wp post create --post_content="I have a pen, I have an apple. Pen, pine-apple, apple-pen."`
1037+
1038+
When I run `wp search-replace --regex "ap{2}le" "orange" --regex-limit=1 --log`
1039+
Then STDOUT should contain:
1040+
"""
1041+
I have a pen, I have an orange. Pen, pine-apple, apple-pen.
1042+
"""
1043+
1044+
1045+
Scenario: Regex search/replace with `--regex-limit=2` option
1046+
Given a WP install
1047+
And I run `wp post create --post_content="I have a pen, I have an apple. Pen, pine-apple, apple-pen."`
1048+
1049+
When I run `wp search-replace --regex "ap{2}le" "orange" --regex-limit=2 --log`
1050+
Then STDOUT should contain:
1051+
"""
1052+
I have a pen, I have an orange. Pen, pine-orange, apple-pen.
1053+
"""

0 commit comments

Comments
 (0)