Changeset 31615 for trunk/tests/phpunit/tests/comment.php
- Timestamp:
- 03/05/2015 02:59:47 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/comment.php
r31195 r31615 73 73 $this->assertSame( array(), $found ); 74 74 } 75 76 /** 77 * @ticket 14279 78 */ 79 public function test_wp_new_comment_respects_dates() { 80 // `wp_new_comment()` checks REMOTE_ADDR, so we fake it to avoid PHP notices. 81 if ( isset( $_SERVER['REMOTE_ADDR'] ) ) { 82 $remote_addr = $_SERVER['REMOTE_ADDR']; 83 } else { 84 $_SERVER['REMOTE_ADDR'] = ''; 85 } 86 87 $u = $this->factory->user->create(); 88 $post_id = $this->factory->post->create( array( 'post_author' => $u ) ); 89 90 $data = array( 91 'comment_post_ID' => $post_id, 92 'comment_author' => rand_str(), 93 'comment_author_url' => '', 94 'comment_author_email' => '', 95 'comment_type' => '', 96 'comment_content' => rand_str(), 97 'comment_date' => '2011-01-01 10:00:00', 98 'comment_date_gmt' => '2011-01-01 10:00:00', 99 ); 100 101 $id = wp_new_comment( $data ); 102 103 $comment = get_comment( $id ); 104 105 $this->assertEquals( $data['comment_date'], $comment->comment_date ); 106 $this->assertEquals( $data['comment_date_gmt'], $comment->comment_date_gmt ); 107 108 // Cleanup. 109 if ( isset( $remote_addr ) ) { 110 $_SERVER['REMOTE_ADDR'] = $remote_addr; 111 } else { 112 unset( $_SERVER['REMOTE_ADDR'] ); 113 } 114 } 75 115 }
Note: See TracChangeset
for help on using the changeset viewer.