WordPress.org

Make WordPress Core


Ignore:
Timestamp:
04/27/2015 02:02:45 PM (5 years ago)
Author:
pento
Message:

WPDB: Sanity check that any strings being stored in the DB are not too long to store correctly.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/comment.php

    r31615 r32299  
    113113        }
    114114    }
     115
     116    public function test_comment_field_lengths() {
     117        // `wp_new_comment()` checks REMOTE_ADDR, so we fake it to avoid PHP notices.
     118        if ( isset( $_SERVER['REMOTE_ADDR'] ) ) {
     119            $remote_addr = $_SERVER['REMOTE_ADDR'];
     120        } else {
     121            $_SERVER['REMOTE_ADDR'] = '';
     122        }
     123
     124        $post_id = $this->factory->post->create();
     125
     126        $data = array(
     127            'comment_post_ID' => $post_id,
     128            'comment_author' => rand_str(),
     129            'comment_author_url' => '',
     130            'comment_author_email' => '',
     131            'comment_type' => '',
     132            'comment_content' => str_repeat( 'A', 65536 ),
     133            'comment_date' => '2011-01-01 10:00:00',
     134            'comment_date_gmt' => '2011-01-01 10:00:00',
     135        );
     136
     137        $id = wp_new_comment( $data );
     138
     139        $this->assertFalse( $id );
     140    }
    115141}
Note: See TracChangeset for help on using the changeset viewer.