Skip to content

Commit 5ffe00f

Browse files
committed
Add coverage tests and ignore annotation for defensive code
1 parent 60d0715 commit 5ffe00f

2 files changed

Lines changed: 34 additions & 1 deletion

File tree

features/search-replace-url.feature

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,3 +632,36 @@ Feature: URL-optimized search/replace with smart column skipping
632632
"""
633633
And the return code should be 1
634634

635+
@require-mysql
636+
Scenario: Error when --analyze-tables used without --smart-url
637+
Given a WP install
638+
639+
When I try `wp search-replace 'foo' 'bar' --analyze-tables`
640+
Then STDERR should contain:
641+
"""
642+
Error: The --analyze-tables flag requires --smart-url to be enabled.
643+
"""
644+
And the return code should be 1
645+
646+
@require-mysql
647+
Scenario: Table analysis skips SET columns
648+
Given a WP install
649+
And I run `wp db query "CREATE TABLE wp_test_set (id INT PRIMARY KEY, permissions SET('read','write','delete'), data TEXT)"`
650+
651+
When I run `wp db query "INSERT INTO wp_test_set VALUES (1, 'read,write', 'http://set.test')"`
652+
Then STDERR should be empty
653+
654+
When I run `wp search-replace --smart-url 'http://set.test' 'http://set.com' wp_test_set --analyze-tables --all-tables-with-prefix`
655+
Then STDOUT should contain:
656+
"""
657+
Success:
658+
"""
659+
660+
When I run `wp db query "SELECT data FROM wp_test_set WHERE id = 1" --skip-column-names`
661+
Then STDOUT should contain:
662+
"""
663+
http://set.com
664+
"""
665+
666+
When I run `wp db query "DROP TABLE wp_test_set"`
667+
Then STDERR should be empty

src/Search_Replace_Command.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,7 @@ private function analyze_tables_for_skip_columns( $tables ) {
12871287
);
12881288

12891289
if ( empty( $columns ) ) {
1290-
continue;
1290+
continue; // @codeCoverageIgnore
12911291
}
12921292

12931293
foreach ( $columns as $col ) {

0 commit comments

Comments
 (0)