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:
Gary Pendergast
2015-04-27 14:02:45 +00:00
parent ca8d6fb60f
commit 45b0abbef1
3 changed files with 141 additions and 0 deletions

View File

@@ -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 );
}
}