| | 944 | * @ticket 32315 |
| | 945 | * |
| | 946 | * @dataProvider data_process_fields_invalid_data |
| | 947 | */ |
| | 948 | function test_process_fields_value_too_long_for_field( $data ) { |
| | 949 | |
| | 950 | global $wpdb; |
| | 951 | |
| | 952 | $this->assertFalse( self::$_wpdb->process_fields( $wpdb->posts, $data, null ) ); |
| | 953 | $this->assertSame( |
| | 954 | '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.', |
| | 955 | self::$_wpdb->last_error |
| | 956 | ); |
| | 957 | } |
| | 958 | |
| | 959 | function data_process_fields_invalid_data() { |
| | 960 | return array( |
| | 961 | 'too_long' => array( array( 'post_status' => str_repeat( 'a', 21 ) ) ), |
| | 962 | 'invalid_chars' => array( array( 'post_status' => "\xF5" ) ), |
| | 963 | ); |
| | 964 | } |
| | 965 | |
| | 966 | /** |
| | 967 | * @ticket 32315 |
| | 968 | */ |
| | 969 | function test_process_fields_value_too_long_for_field_multiple() { |
| | 970 | |
| | 971 | global $wpdb; |
| | 972 | |
| | 973 | $data = array( |
| | 974 | 'post_status' => str_repeat( 'a', 21 ), |
| | 975 | 'post_content' => "\xF5", |
| | 976 | ); |
| | 977 | |
| | 978 | $this->assertFalse( self::$_wpdb->process_fields( $wpdb->posts, $data, null ) ); |
| | 979 | $this->assertSame( |
| | 980 | '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.', |
| | 981 | self::$_wpdb->last_error |
| | 982 | ); |
| | 983 | } |
| | 984 | |
| | 985 | /** |
| | 986 | * @ticket 32315 |
| | 987 | * |
| | 988 | * @dataProvider data_process_fields_invalid_data |
| | 989 | */ |
| | 990 | function test_insert_value_too_long_for_field( $data ) { |
| | 991 | |
| | 992 | global $wpdb; |
| | 993 | |
| | 994 | $this->assertFalse( $wpdb->insert( $wpdb->posts, $data ) ); |
| | 995 | $this->assertSame( |
| | 996 | '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.', |
| | 997 | $wpdb->last_error |
| | 998 | ); |
| | 999 | } |
| | 1000 | |
| | 1001 | /** |
| | 1002 | * @ticket 32315 |
| | 1003 | * |
| | 1004 | * @dataProvider data_process_fields_invalid_data |
| | 1005 | */ |
| | 1006 | function test_replace_value_too_long_for_field( $data ) { |
| | 1007 | |
| | 1008 | global $wpdb; |
| | 1009 | |
| | 1010 | $this->assertFalse( $wpdb->replace( $wpdb->posts, $data ) ); |
| | 1011 | $this->assertSame( |
| | 1012 | '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.', |
| | 1013 | $wpdb->last_error |
| | 1014 | ); |
| | 1015 | } |
| | 1016 | |
| | 1017 | /** |
| | 1018 | * @ticket 32315 |
| | 1019 | * |
| | 1020 | * @dataProvider data_process_fields_invalid_data |
| | 1021 | */ |
| | 1022 | function test_update_value_too_long_for_field( $data ) { |
| | 1023 | |
| | 1024 | global $wpdb; |
| | 1025 | |
| | 1026 | $this->assertFalse( $wpdb->update( $wpdb->posts, $data, array() ) ); |
| | 1027 | $this->assertSame( |
| | 1028 | '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.', |
| | 1029 | $wpdb->last_error |
| | 1030 | ); |
| | 1031 | } |
| | 1032 | |
| | 1033 | /** |
| | 1034 | * @ticket 32315 |
| | 1035 | * |
| | 1036 | * @dataProvider data_process_fields_invalid_data |
| | 1037 | */ |
| | 1038 | function test_delete_value_too_long_for_field( $data ) { |
| | 1039 | |
| | 1040 | global $wpdb; |
| | 1041 | |
| | 1042 | $this->assertFalse( $wpdb->delete( $wpdb->posts, $data, array() ) ); |
| | 1043 | $this->assertSame( |
| | 1044 | '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.', |
| | 1045 | $wpdb->last_error |
| | 1046 | ); |
| | 1047 | } |
| | 1048 | |
| | 1049 | /** |
| | 1050 | * @ticket 32315 |
| | 1051 | */ |
| | 1052 | function test_query_value_contains_invalid_chars() { |
| | 1053 | |
| | 1054 | global $wpdb; |
| | 1055 | |
| | 1056 | $this->assertFalse( |
| | 1057 | $wpdb->query( "INSERT INTO {$wpdb->posts} (post_status) VALUES ('\xF5')" ) |
| | 1058 | ); |
| | 1059 | $this->assertSame( |
| | 1060 | 'WordPress Database Error: Could not perform query because it contains invalid data.', |
| | 1061 | $wpdb->last_error |
| | 1062 | ); |
| | 1063 | } |
| | 1064 | |
| | 1065 | /** |