| 234 | /** |
| 235 | * @ticket 21963 |
| 236 | */ |
| 237 | function test_update_attachment_fields() { |
| 238 | $filename = ( DIR_TESTDATA . '/images/test-image.jpg' ); |
| 239 | $contents = file_get_contents($filename); |
| 240 | |
| 241 | $upload = wp_upload_bits( basename( $filename ), null, $contents ); |
| 242 | $this->assertTrue( empty( $upload['error'] ) ); |
| 243 | |
| 244 | $id = $this->_make_attachment( $upload ); |
| 245 | |
| 246 | $attached_file = get_post_meta( $id, '_wp_attached_file', true ); |
| 247 | |
| 248 | $post = get_post( $id, ARRAY_A ); |
| 249 | |
| 250 | $post['post_title'] = 'title'; |
| 251 | $post['post_excerpt'] = 'caption'; |
| 252 | $post['post_content'] = 'description'; |
| 253 | |
| 254 | wp_update_post( $post ); |
| 255 | |
| 256 | // Make sure the update didn't remove the attached file. |
| 257 | $this->assertEquals( $attached_file, get_post_meta( $id, '_wp_attached_file', true ) ); |
| 258 | } |
| 259 | |