Skip to content

Commit

Permalink
Skip broken SQLite testing for now
Browse files Browse the repository at this point in the history
  • Loading branch information
schlessera committed Dec 19, 2023
1 parent 43abfb5 commit da1acc7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 5 deletions.
9 changes: 9 additions & 0 deletions features/search-replace-export.feature
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Feature: Search / replace with file export

@require-mysql
Scenario: Search / replace export to STDOUT
Given a WP install
And I run `echo ' '`
Expand Down Expand Up @@ -76,6 +77,7 @@ Feature: Search / replace with file export
https://example.net
"""

@require-mysql
Scenario: Search / replace export to file
Given a WP install
And I run `wp post generate --count=100`
Expand Down Expand Up @@ -129,6 +131,7 @@ Feature: Search / replace with file export
101
"""

@require-mysql
Scenario: Search / replace export to file with verbosity
Given a WP install

Expand All @@ -151,6 +154,7 @@ Feature: Search / replace with file export
Error: You cannot supply --dry-run and --export at the same time.
"""

@require-mysql
Scenario: Search / replace shouldn't affect primary key
Given a WP install
And I run `wp post create --post_title=foo --porcelain`
Expand Down Expand Up @@ -191,6 +195,7 @@ Feature: Search / replace with file export
Error: Unable to open export file "foo/bar.sql" for writing:
"""

@require-mysql
Scenario: Search / replace specific table
Given a WP install

Expand Down Expand Up @@ -225,6 +230,7 @@ Feature: Search / replace with file export
foo
"""

@require-mysql
Scenario: Search / replace export should cater for field/table names that use reserved words or unusual characters
Given a WP install
# Unlike search-replace.features version, don't use `back``tick` column name as WP_CLI\Iterators\Table::build_fields() can't handle it.
Expand Down Expand Up @@ -268,6 +274,7 @@ Feature: Search / replace with file export
"""
And STDERR should be empty

@require-mysql
Scenario: Suppress report or only report changes on export to file
Given a WP install

Expand Down Expand Up @@ -365,6 +372,7 @@ Feature: Search / replace with file export
"""
And STDERR should be empty

@require-mysql
Scenario: Search / replace should remove placeholder escape on export
Given a WP install
And I run `wp post create --post_title=test-remove-placeholder-escape% --porcelain`
Expand All @@ -380,6 +388,7 @@ Feature: Search / replace with file export
'test-remove-placeholder-escape{'
"""

@require-mysql
Scenario: NULLs exported as NULL and not null string
Given a WP install
And I run `wp db query "INSERT INTO wp_postmeta VALUES (9999, 9999, NULL, 'foo')"`
Expand Down
33 changes: 28 additions & 5 deletions features/search-replace.feature
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Feature: Do global search/replace

@require-mysql
Scenario: Basic search/replace
Given a WP install

Expand Down Expand Up @@ -41,6 +42,7 @@ Feature: Do global search/replace
| wp_posts | post_content | 0 | SQL |


@require-mysql
Scenario: Multisite search/replace
Given a WP multisite install
And I run `wp site create --slug="foo" --title="foo" --email="[email protected]"`
Expand All @@ -50,6 +52,7 @@ Feature: Do global search/replace
| wp_2_options | option_value | 4 | PHP |
| wp_blogs | path | 1 | SQL |

@require-mysql
Scenario: Don't run on unregistered tables by default
Given a WP install
And I run `wp db query "CREATE TABLE wp_awesome ( id int(11) unsigned NOT NULL AUTO_INCREMENT, awesome_stuff TEXT, PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=latin1;"`
Expand All @@ -66,6 +69,7 @@ Feature: Do global search/replace
wp_awesome
"""

@require-mysql
Scenario: Run on unregistered, unprefixed tables with --all-tables flag
Given a WP install
And I run `wp db query "CREATE TABLE awesome_table ( id int(11) unsigned NOT NULL AUTO_INCREMENT, awesome_stuff TEXT, PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=latin1;"`
Expand All @@ -82,6 +86,7 @@ Feature: Do global search/replace
awesome_table
"""

@require-mysql
Scenario: Run on all tables matching string with wildcard
Given a WP install

Expand Down Expand Up @@ -154,12 +159,14 @@ Feature: Do global search/replace
bar
"""

@require-mysql
Scenario: Quiet search/replace
Given a WP install

When I run `wp search-replace foo bar --quiet`
Then STDOUT should be empty

@require-mysql
Scenario: Verbose search/replace
Given a WP install
And I run `wp post create --post_title='Replace this text' --porcelain`
Expand Down Expand Up @@ -202,6 +209,7 @@ Feature: Do global search/replace
"""
And the return code should be 1

@require-mysql
Scenario: Search and replace within theme mods
Given a WP install
And a setup-theme-mod.php file:
Expand Down Expand Up @@ -231,6 +239,7 @@ Feature: Do global search/replace
| key | value |
| header_image_data | {"url":"https:\/\/example.com\/foo.jpg"} |

@require-mysql
Scenario: Search and replace with quoted strings
Given a WP install

Expand Down Expand Up @@ -276,6 +285,7 @@ Feature: Do global search/replace
And STDOUT should be empty
And the return code should be 0

@require-mysql
Scenario: Search and replace a table that has a multi-column primary key
Given a WP install
And I run `wp db query "CREATE TABLE wp_multicol ( "id" bigint(20) NOT NULL AUTO_INCREMENT,"name" varchar(60) NOT NULL,"value" text NOT NULL,PRIMARY KEY ("id","name"),UNIQUE KEY "name" ("name") ) ENGINE=InnoDB DEFAULT CHARSET=utf8 "`
Expand Down Expand Up @@ -308,6 +318,7 @@ Feature: Do global search/replace
| https://newdomain.com | |
| https://newdomain.com | --dry-run |

@require-mysql
Scenario Outline: Choose replacement method (PHP or MySQL/MariaDB) given proper flags or data.
Given a WP install
And I run `wp option get siteurl`
Expand All @@ -324,6 +335,7 @@ Feature: Do global search/replace
| | PHP | SQL |
| --precise | PHP | PHP |

@require-mysql
Scenario Outline: Ensure search and replace uses PHP (precise) mode when serialized data is found
Given a WP install
And I run `wp post create --post_content='<input>' --porcelain`
Expand All @@ -346,6 +358,7 @@ Feature: Do global search/replace
| a:1:{s:3:"bar";s:3:"foo";} |
| O:8:"stdClass":1:{s:1:"a";s:3:"foo";} |

@require-mysql
Scenario: Search replace with a regex flag
Given a WP install

Expand All @@ -371,6 +384,7 @@ Feature: Do global search/replace
https://BAXAMPLE.com
"""

@require-mysql
Scenario: Search replace with a regex delimiter
Given a WP install

Expand Down Expand Up @@ -469,6 +483,7 @@ Feature: Do global search/replace
"""
And the return code should be 1

@require-mysql
Scenario: Formatting as count-only
Given a WP install
And I run `wp option set foo 'ALPHA.example.com'`
Expand Down Expand Up @@ -498,6 +513,7 @@ Feature: Do global search/replace
0
"""

@require-mysql
Scenario: Search / replace should cater for field/table names that use reserved words or unusual characters
Given a WP install
And a esc_sql_ident.sql file:
Expand Down Expand Up @@ -525,7 +541,7 @@ Feature: Do global search/replace
"""
And STDERR should be empty

@suppress_report__only_changes
@require-mysql @suppress_report__only_changes
Scenario: Suppress report or only report changes
Given a WP install

Expand Down Expand Up @@ -634,7 +650,7 @@ Feature: Do global search/replace
"""
And STDERR should be empty

@no_table__no_primary_key
@require-mysql @no_table__no_primary_key
Scenario: Deal with non-existent table and table with no primary keys
Given a WP install

Expand Down Expand Up @@ -684,6 +700,7 @@ Feature: Do global search/replace
"""
And the return code should be 0

@require-mysql
Scenario: Search / replace is case sensitive
Given a WP install
When I run `wp post create --post_title='Case Sensitive' --porcelain`
Expand Down Expand Up @@ -717,6 +734,7 @@ Feature: Do global search/replace
"""
And STDERR should be empty

@require-mysql
Scenario: Logging with simple replace
Given a WP install

Expand Down Expand Up @@ -932,6 +950,7 @@ Feature: Do global search/replace
Content_ab\1z__baz_1234567890_eb\1z__bez_1234567890_ib\1z__biz_1234567890_ob\1z__boz_1234567890_ub\1z__buz_
"""

@require-mysql
Scenario: Logging with prefixes and custom colors
Given a WP install
And I run `wp option set blogdescription 'Just another WordPress site'`
Expand Down Expand Up @@ -1032,6 +1051,7 @@ Feature: Do global search/replace
And STDERR should be empty

# Regression test for https://github.com/wp-cli/search-replace-command/issues/58
@require-mysql
Scenario: The parameters --regex and --all-tables-with-prefix produce valid SQL
Given a WP install
And a test_db.sql file:
Expand Down Expand Up @@ -1085,6 +1105,7 @@ Feature: Do global search/replace
"""

# Regression test for https://github.com/wp-cli/search-replace-command/issues/68
@require-mysql
Scenario: Incomplete classes are handled gracefully during (un)serialization

Given a WP install
Expand All @@ -1106,7 +1127,7 @@ Feature: Do global search/replace
a:1:{i:0;O:10:"CornFlakes":0:{}}
"""

@less-than-php-8.0
@require-mysql @less-than-php-8.0
Scenario: Warn and ignore type-hinted objects that have some error in deserialization (PHP < 8.0)
Given a WP install
And I run `wp db query "INSERT INTO wp_options (option_name,option_value) VALUES ('cereal_isation','O:13:\"mysqli_result\":5:{s:13:\"current_field\";N;s:11:\"field_count\";N;s:7:\"lengths\";N;s:8:\"num_rows\";N;s:4:\"type\";N;}')"`
Expand Down Expand Up @@ -1147,7 +1168,7 @@ Feature: Do global search/replace
[field_count] => 2
"""

@require-php-8.0 @less-than-php-8.1
@require-mysql @require-php-8.0 @less-than-php-8.1
Scenario: Warn and ignore type-hinted objects that have some error in deserialization (PHP 8.0)
Given a WP install
And I run `wp db query "INSERT INTO wp_options (option_name,option_value) VALUES ('cereal_isation','O:13:\"mysqli_result\":5:{s:13:\"current_field\";N;s:11:\"field_count\";N;s:7:\"lengths\";N;s:8:\"num_rows\";N;s:4:\"type\";N;}')"`
Expand Down Expand Up @@ -1188,7 +1209,7 @@ Feature: Do global search/replace
[field_count] => 2
"""

@require-php-8.1
@require-mysql @require-php-8.1
Scenario: Warn and ignore type-hinted objects that have some error in deserialization (PHP 8.1+)
Given a WP install
And I run `wp db query "INSERT INTO wp_options (option_name,option_value) VALUES ('cereal_isation','O:13:\"mysqli_result\":5:{s:13:\"current_field\";N;s:11:\"field_count\";N;s:7:\"lengths\";N;s:8:\"num_rows\";N;s:4:\"type\";N;}')"`
Expand Down Expand Up @@ -1272,6 +1293,7 @@ Feature: Do global search/replace
Success:
"""

@require-mysql
Scenario: Chunking a precise search and replace works without skipping lines
Given a WP install
And a create_sql_file.sh file:
Expand Down Expand Up @@ -1323,6 +1345,7 @@ Feature: Do global search/replace
Success: Made 0 replacements.
"""

@require-mysql
Scenario: Chunking a regex search and replace works without skipping lines
Given a WP install
And a create_sql_file.sh file:
Expand Down

0 comments on commit da1acc7

Please sign in to comment.