Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 50 additions & 32 deletions features/db-search.feature
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ Feature: Search through the database
4:example.com example.com
"""

When I run `wp db query "SELECT option_id FROM wp_options WHERE option_name = 'siteurl';" --skip-column-names | cat`
Then save STDOUT as {SITEURL_ID}

When I run `wp db search example.com`
Then STDOUT should contain:
"""
wp_options:option_value
1:https://example.com
{SITEURL_ID}:https://example.com
"""
And STDOUT should not contain:
"""
Expand All @@ -44,7 +47,7 @@ Feature: Search through the database
Then STDOUT should contain:
"""
wp_options:option_value
1:https://example.com
{SITEURL_ID}:https://example.com
"""
And STDOUT should not contain:
"""
Expand All @@ -60,7 +63,7 @@ Feature: Search through the database
Then STDOUT should contain:
"""
wp_options:option_value
1:example.com
{SITEURL_ID}:example.com
"""
And STDOUT should not contain:
"""
Expand All @@ -79,7 +82,7 @@ Feature: Search through the database
Then STDOUT should contain:
"""
wp_options:option_value
1:example.com
{SITEURL_ID}:example.com
"""
And STDOUT should contain:
"""
Expand All @@ -105,7 +108,7 @@ Feature: Search through the database
Then STDOUT should contain:
"""
wp_options:option_value
1:example.com
{SITEURL_ID}:example.com
"""
And STDOUT should not contain:
"""
Expand All @@ -121,7 +124,7 @@ Feature: Search through the database
Then STDOUT should contain:
"""
wp_options:option_value
1:example.com
{SITEURL_ID}:example.com
"""
And STDOUT should not contain:
"""
Expand All @@ -148,7 +151,7 @@ Feature: Search through the database
Then STDOUT should contain:
"""
wp_options:option_value
1:example.com
{SITEURL_ID}:example.com
"""
And STDOUT should contain:
"""
Expand All @@ -174,7 +177,7 @@ Feature: Search through the database
Then STDOUT should contain:
"""
wp_options:option_value
1:example.com
{SITEURL_ID}:example.com
"""
And STDOUT should contain:
"""
Expand Down Expand Up @@ -290,6 +293,9 @@ Feature: Search through the database
And I run `wp db query "CREATE TABLE pw_options ( id int(11) unsigned NOT NULL AUTO_INCREMENT, awesome_stuff TEXT, PRIMARY KEY (id) );"`
And I run `wp db query "INSERT INTO pw_options (awesome_stuff) VALUES ('example.com'), ('e_ample.c%m');"`

When I run `wp db query "SELECT option_id FROM wp_options WHERE option_name = 'siteurl';" --skip-column-names | cat`
Then save STDOUT as {SITEURL_ID}

When I run `wp db query "SELECT CONCAT( id, ':', awesome_stuff) FROM wp_not ORDER BY id;" --skip-column-names`
Then STDOUT should be:
"""
Expand All @@ -313,7 +319,7 @@ Feature: Search through the database
Then STDOUT should contain:
"""
wp_options:option_value
1:https://example.com
{SITEURL_ID}:https://example.com
"""
And STDOUT should not contain:
"""
Expand All @@ -337,7 +343,7 @@ Feature: Search through the database
Then STDOUT should contain:
"""
wp_options:option_value
1:https://example.com
{SITEURL_ID}:https://example.com
"""
And STDOUT should not contain:
"""
Expand Down Expand Up @@ -385,12 +391,12 @@ Feature: Search through the database
Then STDOUT should contain:
"""
wp_options:option_value
1:https://example.com
{SITEURL_ID}:https://example.com
"""
And STDOUT should contain:
"""
wp_2_options:option_value
1:https://example.com/foo
{SITEURL_ID}:https://example.com/foo
"""
And STDOUT should not contain:
"""
Expand All @@ -410,7 +416,7 @@ Feature: Search through the database
Then STDOUT should contain:
"""
wp_options:option_value
1:https://example.com
{SITEURL_ID}:https://example.com
"""
And STDOUT should not contain:
"""
Expand All @@ -434,7 +440,7 @@ Feature: Search through the database
Then STDOUT should contain:
"""
wp_options:option_value
1:https://example.com
{SITEURL_ID}:https://example.com
"""
And STDOUT should contain:
"""
Expand All @@ -461,7 +467,7 @@ Feature: Search through the database
Then STDOUT should contain:
"""
wp_options:option_value
1:https://example.com
{SITEURL_ID}:https://example.com
"""
And STDOUT should not contain:
"""
Expand Down Expand Up @@ -510,7 +516,7 @@ Feature: Search through the database
Then STDOUT should contain:
"""
wp_options:option_value
1:https://example.com
{SITEURL_ID}:https://example.com
"""
And STDOUT should contain:
"""
Expand Down Expand Up @@ -538,7 +544,7 @@ Feature: Search through the database
Then STDOUT should contain:
"""
wp_options:option_value
1:https://example.com
{SITEURL_ID}:https://example.com
"""
And STDOUT should contain:
"""
Expand Down Expand Up @@ -705,6 +711,9 @@ Feature: Search through the database

Scenario: Search with regular expressions
Given a WP install
When I run `wp db query "SELECT option_id FROM wp_options WHERE option_name = 'siteurl';" --skip-column-names | cat`
Then save STDOUT as {SITEURL_ID}

And I run `wp option update regextst '12345é789あhttps://regextst.com1234567890123456789éhttps://regextst.com12345678901234567890regextst.com34567890t.com67890'`
# Note ö is o with combining umlaut.
And I run `wp option update regextst_combining 'lllllムnöppppp'`
Expand All @@ -713,7 +722,7 @@ Feature: Search through the database
Then STDOUT should contain:
"""
wp_options:option_value
1:https://example.com
{SITEURL_ID}:https://example.com
"""
And STDOUT should not contain:
"""
Expand Down Expand Up @@ -865,35 +874,41 @@ Feature: Search through the database
Scenario: Search with output options
Given a WP install

When I run `wp db query "SELECT option_id FROM wp_options WHERE option_name = 'siteurl';" --skip-column-names | cat`
Then save STDOUT as {SITEURL_ID}

When I run `wp db query "SELECT option_id FROM wp_options WHERE option_name = 'home';" --skip-column-names | cat`
Then save STDOUT as {HOMEURL_ID}

When I run `wp db search example.com`
Then STDOUT should contain:
"""
wp_options:option_value
1:https://example.com
{SITEURL_ID}:https://example.com
wp_options:option_value
2:https://example.com
{HOMEURL_ID}:https://example.com
"""

When I run `wp db search example.com --table_column_once`
Then STDOUT should contain:
"""
wp_options:option_value
1:https://example.com
2:https://example.com
{SITEURL_ID}:https://example.com
{HOMEURL_ID}:https://example.com
"""

When I run `wp db search example.com --one_line`
Then STDOUT should contain:
"""
wp_options:option_value:1:https://example.com
wp_options:option_value:2:https://example.com
wp_options:option_value:{SITEURL_ID}:https://example.com
wp_options:option_value:{HOMEURL_ID}:https://example.com
"""

When I run `wp db search example.com --table_column_once --one_line`
Then STDOUT should contain:
"""
wp_options:option_value:1:https://example.com
wp_options:option_value:2:https://example.com
wp_options:option_value:{SITEURL_ID}:https://example.com
wp_options:option_value:{HOMEURL_ID}:https://example.com
"""

When I run `wp db search example.com --all-tables --before_context=0 --after_context=0 --matches_only`
Expand All @@ -917,46 +932,49 @@ Feature: Search through the database
Scenario: Search with custom colors
Given a WP install

When I run `wp db query "SELECT option_id FROM wp_options WHERE option_name = 'siteurl';" --skip-column-names | cat`
Then save STDOUT as {SITEURL_ID}

When I run `SHELL_PIPE=0 wp db search example.com`
Then STDOUT should strictly contain:
"""
wp_options:option_value
1:https://example.com
{SITEURL_ID}:https://example.com
"""

When I run `SHELL_PIPE=0 wp db search example.com --table_column_color=%r --id_color=%g --match_color=%b`
Then STDOUT should strictly contain:
"""
wp_options:option_value
1:https://example.com
{SITEURL_ID}:https://example.com
"""

When I run `SHELL_PIPE=0 wp db search example.com --table_column_color=%r`
Then STDOUT should strictly contain:
"""
wp_options:option_value
1:https://example.com
{SITEURL_ID}:https://example.com
"""

When I run `SHELL_PIPE=0 wp db search example.com --id_color=%g`
Then STDOUT should strictly contain:
"""
wp_options:option_value
1:https://example.com
{SITEURL_ID}:https://example.com
"""

When I run `SHELL_PIPE=0 wp db search example.com --match_color=%b`
Then STDOUT should strictly contain:
"""
wp_options:option_value
1:https://example.com
{SITEURL_ID}:https://example.com
"""

When I run `SHELL_PIPE=0 wp db search example.com --before_context=0 --after_context=0`
Then STDOUT should strictly contain:
"""
wp_options:option_value
1:example.com
{SITEURL_ID}:example.com
"""

When I try `wp db search example.com --match_color=%x`
Expand Down