Skip to content

Commit b3a1734

Browse files
committed
Split into two separate tests per PHP version
1 parent 251042b commit b3a1734

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

features/search-replace.feature

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1106,7 +1106,49 @@ Feature: Do global search/replace
11061106
a:1:{i:0;O:10:"CornFlakes":0:{}}
11071107
"""
11081108

1109-
Scenario: Warn and ignore type-hinted objects that have some error in deserialization
1109+
@less-than-php-8.1
1110+
Scenario: Warn and ignore type-hinted objects that have some error in deserialization (PHP < 8.1)
1111+
Given a WP install
1112+
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;}')"`
1113+
And I run `wp db query "INSERT INTO wp_options (option_name,option_value) VALUES ('cereal_isation_2','O:8:\"mysqli_result\":5:{s:13:\"current_field\";i:1;s:11:\"field_count\";i:2;s:7:\"lengths\";a:1:{i:0;s:4:\"blah\";}s:8:\"num_rows\";i:1;s:4:\"type\";i:2;}')"`
1114+
1115+
When I try `wp search-replace mysqli_result stdClass`
1116+
Then STDERR should contain:
1117+
"""
1118+
Warning: Warning: Skipping an inconvertible serialized object of type "mysqli_result", replacements might not be complete. Reason: mysqli_result object is already closed.
1119+
"""
1120+
And STDOUT should contain:
1121+
"""
1122+
Success: Made 1 replacement.
1123+
"""
1124+
1125+
When I run `wp db query "SELECT option_value from wp_options where option_name='cereal_isation_2'" --skip-column-names`
1126+
Then STDOUT should contain:
1127+
"""
1128+
O:8:"stdClass":5:{s:13:"current_field";i:1;s:11:"field_count";i:2;s:7:"lengths";a:1:{i:0;s:4:"blah";}s:8:"num_rows";i:1;s:4:"type";i:2;}
1129+
"""
1130+
Then save STDOUT as {SERIALIZED_RESULT}
1131+
And a test_php.php file:
1132+
"""
1133+
<?php print_r(unserialize('{SERIALIZED_RESULT}'));
1134+
"""
1135+
1136+
When I try `wp eval-file test_php.php`
1137+
Then STDOUT should contain:
1138+
"""
1139+
stdClass Object
1140+
"""
1141+
Then STDOUT should contain:
1142+
"""
1143+
[current_field] => 1
1144+
"""
1145+
Then STDOUT should contain:
1146+
"""
1147+
[field_count] => 2
1148+
"""
1149+
1150+
@require-php-8.1
1151+
Scenario: Warn and ignore type-hinted objects that have some error in deserialization (PHP 8.1+)
11101152
Given a WP install
11111153
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;}')"`
11121154
And I run `wp db query "INSERT INTO wp_options (option_name,option_value) VALUES ('cereal_isation_2','O:8:\"mysqli_result\":5:{s:13:\"current_field\";i:1;s:11:\"field_count\";i:2;s:7:\"lengths\";a:1:{i:0;s:4:\"blah\";}s:8:\"num_rows\";i:1;s:4:\"type\";i:2;}')"`

0 commit comments

Comments
 (0)