| | 116 | /** |
| | 117 | * @ticket 14601 |
| | 118 | */ |
| | 119 | public function test_wp_new_comment_respects_author_ip() { |
| | 120 | $u = $this->factory->user->create(); |
| | 121 | $post_id = $this->factory->post->create( array( 'post_author' => $u ) ); |
| | 122 | |
| | 123 | $data = array( |
| | 124 | 'comment_post_ID' => $post_id, |
| | 125 | 'comment_author' => rand_str(), |
| | 126 | 'comment_author_IP' => '192.168.1.1', |
| | 127 | 'comment_author_url' => '', |
| | 128 | 'comment_author_email' => '', |
| | 129 | 'comment_type' => '', |
| | 130 | 'comment_content' => rand_str(), |
| | 131 | ); |
| | 132 | |
| | 133 | $id = wp_new_comment( $data ); |
| | 134 | |
| | 135 | $comment = get_comment( $id ); |
| | 136 | |
| | 137 | $this->assertEquals( $data['comment_author_IP'], $comment->comment_author_IP ); |
| | 138 | } |
| | 139 | |
| | 140 | /** |
| | 141 | * @ticket 14601 |
| | 142 | */ |
| | 143 | public function test_wp_new_comment_respects_author_ip_empty_string() { |
| | 144 | $u = $this->factory->user->create(); |
| | 145 | $post_id = $this->factory->post->create( array( 'post_author' => $u ) ); |
| | 146 | |
| | 147 | $data = array( |
| | 148 | 'comment_post_ID' => $post_id, |
| | 149 | 'comment_author' => rand_str(), |
| | 150 | 'comment_author_IP' => '', |
| | 151 | 'comment_author_url' => '', |
| | 152 | 'comment_author_email' => '', |
| | 153 | 'comment_type' => '', |
| | 154 | 'comment_content' => rand_str(), |
| | 155 | ); |
| | 156 | |
| | 157 | $id = wp_new_comment( $data ); |
| | 158 | |
| | 159 | $comment = get_comment( $id ); |
| | 160 | |
| | 161 | $this->assertEquals( $data['comment_author_IP'], $comment->comment_author_IP ); |
| | 162 | } |
| | 163 | |
| | 164 | /** |
| | 165 | * @ticket 14601 |
| | 166 | */ |
| | 167 | public function test_wp_new_comment_respects_comment_agent() { |
| | 168 | $u = $this->factory->user->create(); |
| | 169 | $post_id = $this->factory->post->create( array( 'post_author' => $u ) ); |
| | 170 | |
| | 171 | $data = array( |
| | 172 | 'comment_post_ID' => $post_id, |
| | 173 | 'comment_author' => rand_str(), |
| | 174 | 'comment_author_IP' => '', |
| | 175 | 'comment_author_url' => '', |
| | 176 | 'comment_author_email' => '', |
| | 177 | 'comment_agent' => 'Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X; en-us) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53', |
| | 178 | 'comment_type' => '', |
| | 179 | 'comment_content' => rand_str(), |
| | 180 | ); |
| | 181 | |
| | 182 | $id = wp_new_comment( $data ); |
| | 183 | |
| | 184 | $comment = get_comment( $id ); |
| | 185 | |
| | 186 | $this->assertEquals( $data['comment_agent'], $comment->comment_agent ); |
| | 187 | } |
| | 188 | |
| | 189 | /** |
| | 190 | * @ticket 14601 |
| | 191 | */ |
| | 192 | public function test_wp_new_comment_respects_comment_agent_length() { |
| | 193 | $u = $this->factory->user->create(); |
| | 194 | $post_id = $this->factory->post->create( array( 'post_author' => $u ) ); |
| | 195 | |
| | 196 | $data = array( |
| | 197 | 'comment_post_ID' => $post_id, |
| | 198 | 'comment_author' => rand_str(), |
| | 199 | 'comment_author_IP' => '', |
| | 200 | 'comment_author_url' => '', |
| | 201 | 'comment_author_email' => '', |
| | 202 | 'comment_agent' => 'Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X; en-us) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53 Opera/9.80 (X11; Linux i686; Ubuntu/14.10) Presto/2.12.388 Version/12.16 Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en; rv:1.8.1.4pre) Gecko/20070511 Camino/1.6pre', |
| | 203 | 'comment_type' => '', |
| | 204 | 'comment_content' => rand_str(), |
| | 205 | ); |
| | 206 | |
| | 207 | $id = wp_new_comment( $data ); |
| | 208 | |
| | 209 | $comment = get_comment( $id ); |
| | 210 | |
| | 211 | $this->assertEquals( 'Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X; en-us) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53 Opera/9.80 (X11; Linux i686; Ubuntu/14.10) Presto/2.12.388 Version/12.16 Mozilla/5.0 (Macintosh; U; PPC Mac OS ', $comment->comment_agent ); |
| | 212 | } |
| | 213 | |
| | 214 | /** |
| | 215 | * @ticket 14601 |
| | 216 | */ |
| | 217 | public function test_wp_new_comment_respects_comment_agent_empty_string() { |
| | 218 | $u = $this->factory->user->create(); |
| | 219 | $post_id = $this->factory->post->create( array( 'post_author' => $u ) ); |
| | 220 | |
| | 221 | $data = array( |
| | 222 | 'comment_post_ID' => $post_id, |
| | 223 | 'comment_author' => rand_str(), |
| | 224 | 'comment_author_IP' => '', |
| | 225 | 'comment_author_url' => '', |
| | 226 | 'comment_author_email' => '', |
| | 227 | 'comment_agent' => '', |
| | 228 | 'comment_type' => '', |
| | 229 | 'comment_content' => rand_str(), |
| | 230 | ); |
| | 231 | |
| | 232 | $id = wp_new_comment( $data ); |
| | 233 | |
| | 234 | $comment = get_comment( $id ); |
| | 235 | |
| | 236 | $this->assertEquals( $data['comment_agent'], $comment->comment_agent ); |
| | 237 | } |
| | 238 | |
| | 239 | |