| | 1108 | /** |
| | 1109 | + * @ticket 32315 |
| | 1110 | + * |
| | 1111 | + * @dataProvider data_process_fields_invalid_data |
| | 1112 | + */ |
| | 1113 | function test_process_fields_value_too_long_for_field( $data ) { |
| | 1114 | |
| | 1115 | global $wpdb; |
| | 1116 | |
| | 1117 | $this->assertFalse( self::$_wpdb->process_fields( $wpdb->posts, $data, null ) ); |
| | 1118 | $this->assertSame( |
| | 1119 | 'WordPress Database Error: Processing the value for the following field failed, the supplied value may have been too long or contained invalid data: post_status.', |
| | 1120 | self::$_wpdb->last_error |
| | 1121 | ); |
| | 1122 | } |
| | 1123 | |
| | 1124 | function data_process_fields_invalid_data() { |
| | 1125 | return array( |
| | 1126 | 'too_long' => array( array( 'post_status' => str_repeat( 'a', 21 ) ) ), |
| | 1127 | 'invalid_chars' => array( array( 'post_status' => "\xF5" ) ), |
| | 1128 | ); |
| | 1129 | } |
| | 1130 | |
| | 1131 | /** |
| | 1132 | * @ticket 32315 |
| | 1133 | */ |
| | 1134 | function test_process_fields_value_too_long_for_field_multiple() { |
| | 1135 | |
| | 1136 | global $wpdb; |
| | 1137 | |
| | 1138 | $data = array( |
| | 1139 | 'post_status' => str_repeat( 'a', 21 ), |
| | 1140 | 'post_content' => "\xF5", |
| | 1141 | ); |
| | 1142 | |
| | 1143 | $this->assertFalse( self::$_wpdb->process_fields( $wpdb->posts, $data, null ) ); |
| | 1144 | $this->assertSame( |
| | 1145 | 'WordPress Database Error: Processing the values for the following fields failed, the supplied values may have been too long or contained invalid data: post_status, post_content.', |
| | 1146 | self::$_wpdb->last_error |
| | 1147 | ); |
| | 1148 | } |
| | 1149 | |
| | 1150 | /** |
| | 1151 | * @ticket 32315 |
| | 1152 | * |
| | 1153 | * @dataProvider data_process_fields_invalid_data |
| | 1154 | */ |
| | 1155 | function test_insert_value_too_long_for_field( $data ) { |
| | 1156 | |
| | 1157 | global $wpdb; |
| | 1158 | |
| | 1159 | $this->assertFalse( $wpdb->insert( $wpdb->posts, $data ) ); |
| | 1160 | $this->assertSame( |
| | 1161 | 'WordPress Database Error: Processing the value for the following field failed, the supplied value may have been too long or contained invalid data: post_status.', |
| | 1162 | $wpdb->last_error |
| | 1163 | ); |
| | 1164 | } |
| | 1165 | |
| | 1166 | /** |
| | 1167 | * @ticket 32315 |
| | 1168 | * |
| | 1169 | * @dataProvider data_process_fields_invalid_data |
| | 1170 | */ |
| | 1171 | function test_replace_value_too_long_for_field( $data ) { |
| | 1172 | |
| | 1173 | global $wpdb; |
| | 1174 | |
| | 1175 | $this->assertFalse( $wpdb->replace( $wpdb->posts, $data ) ); |
| | 1176 | $this->assertSame( |
| | 1177 | 'WordPress Database Error: Processing the value for the following field failed, the supplied value may have been too long or contained invalid data: post_status.', |
| | 1178 | $wpdb->last_error |
| | 1179 | ); |
| | 1180 | } |
| | 1181 | |
| | 1182 | /** |
| | 1183 | * @ticket 32315 |
| | 1184 | * |
| | 1185 | * @dataProvider data_process_fields_invalid_data |
| | 1186 | */ |
| | 1187 | function test_update_value_too_long_for_field( $data ) { |
| | 1188 | |
| | 1189 | global $wpdb; |
| | 1190 | |
| | 1191 | $this->assertFalse( $wpdb->update( $wpdb->posts, $data, array() ) ); |
| | 1192 | $this->assertSame( |
| | 1193 | 'WordPress Database Error: Processing the value for the following field failed, the supplied value may have been too long or contained invalid data: post_status.', |
| | 1194 | $wpdb->last_error |
| | 1195 | ); |
| | 1196 | } |
| | 1197 | |
| | 1198 | /** |
| | 1199 | * @ticket 32315 |
| | 1200 | * |
| | 1201 | * @dataProvider data_process_fields_invalid_data |
| | 1202 | */ |
| | 1203 | function test_delete_value_too_long_for_field( $data ) { |
| | 1204 | |
| | 1205 | global $wpdb; |
| | 1206 | |
| | 1207 | $this->assertFalse( $wpdb->delete( $wpdb->posts, $data, array() ) ); |
| | 1208 | $this->assertSame( |
| | 1209 | 'WordPress Database Error: Processing the value for the following field failed, the supplied value may have been too long or contained invalid data: post_status.', |
| | 1210 | $wpdb->last_error |
| | 1211 | ); |
| | 1212 | } |
| | 1213 | |
| | 1214 | /** |
| | 1215 | * @ticket 32315 |
| | 1216 | */ |
| | 1217 | function test_query_value_contains_invalid_chars() { |
| | 1218 | |
| | 1219 | global $wpdb; |
| | 1220 | |
| | 1221 | $this->assertFalse( |
| | 1222 | $wpdb->query( "INSERT INTO {$wpdb->posts} (post_status) VALUES ('\xF5')" ) |
| | 1223 | ); |
| | 1224 | |
| | 1225 | $this->assertSame( |
| | 1226 | 'WordPress Database Error: Could not perform query because it contains invalid data.', |
| | 1227 | $wpdb->last_error |
| | 1228 | ); |
| | 1229 | } |
| | 1230 | |