mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-01 11:14:36 +00:00
WPDB: Sanity check that any strings being stored in the DB are not too long to store correctly.
git-svn-id: https://develop.svn.wordpress.org/trunk@32299 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -112,4 +112,30 @@ class Tests_Comment extends WP_UnitTestCase {
|
||||
unset( $_SERVER['REMOTE_ADDR'] );
|
||||
}
|
||||
}
|
||||
|
||||
public function test_comment_field_lengths() {
|
||||
// `wp_new_comment()` checks REMOTE_ADDR, so we fake it to avoid PHP notices.
|
||||
if ( isset( $_SERVER['REMOTE_ADDR'] ) ) {
|
||||
$remote_addr = $_SERVER['REMOTE_ADDR'];
|
||||
} else {
|
||||
$_SERVER['REMOTE_ADDR'] = '';
|
||||
}
|
||||
|
||||
$post_id = $this->factory->post->create();
|
||||
|
||||
$data = array(
|
||||
'comment_post_ID' => $post_id,
|
||||
'comment_author' => rand_str(),
|
||||
'comment_author_url' => '',
|
||||
'comment_author_email' => '',
|
||||
'comment_type' => '',
|
||||
'comment_content' => str_repeat( 'A', 65536 ),
|
||||
'comment_date' => '2011-01-01 10:00:00',
|
||||
'comment_date_gmt' => '2011-01-01 10:00:00',
|
||||
);
|
||||
|
||||
$id = wp_new_comment( $data );
|
||||
|
||||
$this->assertFalse( $id );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user