- Timestamp:
- 08/17/2018 01:50:26 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-attachments-controller.php
r43529 r43571 134 134 // Single 135 135 $attachment_id = $this->factory->attachment->create_object( 136 $this->test_file, 0, array( 136 $this->test_file, 137 0, 138 array( 137 139 'post_mime_type' => 'image/jpeg', 138 140 'post_excerpt' => 'A sample caption', … … 173 175 'slug', 174 176 'status', 175 ), $keys 177 ), 178 $keys 176 179 ); 177 180 $media_types = array( … … 189 192 public function test_registered_get_item_params() { 190 193 $id1 = $this->factory->attachment->create_object( 191 $this->test_file, 0, array( 194 $this->test_file, 195 0, 196 array( 192 197 'post_mime_type' => 'image/jpeg', 193 198 'post_excerpt' => 'A sample caption', … … 205 210 wp_set_current_user( 0 ); 206 211 $id1 = $this->factory->attachment->create_object( 207 $this->test_file, 0, array( 212 $this->test_file, 213 0, 214 array( 208 215 'post_mime_type' => 'image/jpeg', 209 216 'post_excerpt' => 'A sample caption', … … 212 219 $draft_post = $this->factory->post->create( array( 'post_status' => 'draft' ) ); 213 220 $id2 = $this->factory->attachment->create_object( 214 $this->test_file, $draft_post, array( 221 $this->test_file, 222 $draft_post, 223 array( 215 224 'post_mime_type' => 'image/jpeg', 216 225 'post_excerpt' => 'A sample caption', … … 219 228 $published_post = $this->factory->post->create( array( 'post_status' => 'publish' ) ); 220 229 $id3 = $this->factory->attachment->create_object( 221 $this->test_file, $published_post, array( 230 $this->test_file, 231 $published_post, 232 array( 222 233 'post_mime_type' => 'image/jpeg', 223 234 'post_excerpt' => 'A sample caption', … … 239 250 wp_set_current_user( self::$editor_id ); 240 251 $id1 = $this->factory->attachment->create_object( 241 $this->test_file, 0, array( 252 $this->test_file, 253 0, 254 array( 242 255 'post_mime_type' => 'image/jpeg', 243 256 'post_excerpt' => 'A sample caption', … … 246 259 $draft_post = $this->factory->post->create( array( 'post_status' => 'draft' ) ); 247 260 $id2 = $this->factory->attachment->create_object( 248 $this->test_file, $draft_post, array( 261 $this->test_file, 262 $draft_post, 263 array( 249 264 'post_mime_type' => 'image/jpeg', 250 265 'post_excerpt' => 'A sample caption', … … 253 268 $published_post = $this->factory->post->create( array( 'post_status' => 'publish' ) ); 254 269 $id3 = $this->factory->attachment->create_object( 255 $this->test_file, $published_post, array( 270 $this->test_file, 271 $published_post, 272 array( 256 273 'post_mime_type' => 'image/jpeg', 257 274 'post_excerpt' => 'A sample caption', … … 271 288 public function test_get_items_media_type() { 272 289 $id1 = $this->factory->attachment->create_object( 273 $this->test_file, 0, array( 290 $this->test_file, 291 0, 292 array( 274 293 'post_mime_type' => 'image/jpeg', 275 294 ) … … 292 311 public function test_get_items_mime_type() { 293 312 $id1 = $this->factory->attachment->create_object( 294 $this->test_file, 0, array( 313 $this->test_file, 314 0, 315 array( 295 316 'post_mime_type' => 'image/jpeg', 296 317 ) … … 314 335 $post_id = $this->factory->post->create( array( 'post_title' => 'Test Post' ) ); 315 336 $attachment_id = $this->factory->attachment->create_object( 316 $this->test_file, $post_id, array( 337 $this->test_file, 338 $post_id, 339 array( 317 340 'post_mime_type' => 'image/jpeg', 318 341 'post_excerpt' => 'A sample caption', … … 320 343 ); 321 344 $attachment_id2 = $this->factory->attachment->create_object( 322 $this->test_file, 0, array( 345 $this->test_file, 346 0, 347 array( 323 348 'post_mime_type' => 'image/jpeg', 324 349 'post_excerpt' => 'A sample caption', … … 354 379 wp_set_current_user( self::$editor_id ); 355 380 $this->factory->attachment->create_object( 356 $this->test_file, 0, array( 381 $this->test_file, 382 0, 383 array( 357 384 'post_mime_type' => 'image/jpeg', 358 385 'post_excerpt' => 'A sample caption', … … 372 399 wp_set_current_user( 0 ); 373 400 $attachment_id1 = $this->factory->attachment->create_object( 374 $this->test_file, 0, array( 401 $this->test_file, 402 0, 403 array( 375 404 'post_mime_type' => 'image/jpeg', 376 405 'post_excerpt' => 'A sample caption', … … 394 423 wp_set_current_user( 0 ); 395 424 $attachment_id1 = $this->factory->attachment->create_object( 396 $this->test_file, 0, array( 425 $this->test_file, 426 0, 427 array( 397 428 'post_mime_type' => 'image/jpeg', 398 429 'post_excerpt' => 'A sample caption', … … 401 432 ); 402 433 $attachment_id2 = $this->factory->attachment->create_object( 403 $this->test_file, 0, array( 434 $this->test_file, 435 0, 436 array( 404 437 'post_mime_type' => 'image/jpeg', 405 438 'post_excerpt' => 'A sample caption', … … 435 468 public function test_get_items_valid_date() { 436 469 $id1 = $this->factory->attachment->create_object( 437 $this->test_file, 0, array( 470 $this->test_file, 471 0, 472 array( 438 473 'post_date' => '2016-01-15T00:00:00Z', 439 474 'post_mime_type' => 'image/jpeg', … … 442 477 ); 443 478 $id2 = $this->factory->attachment->create_object( 444 $this->test_file, 0, array( 479 $this->test_file, 480 0, 481 array( 445 482 'post_date' => '2016-01-16T00:00:00Z', 446 483 'post_mime_type' => 'image/jpeg', … … 449 486 ); 450 487 $id3 = $this->factory->attachment->create_object( 451 $this->test_file, 0, array( 488 $this->test_file, 489 0, 490 array( 452 491 'post_date' => '2016-01-17T00:00:00Z', 453 492 'post_mime_type' => 'image/jpeg', … … 466 505 public function test_get_item() { 467 506 $attachment_id = $this->factory->attachment->create_object( 468 $this->test_file, 0, array( 507 $this->test_file, 508 0, 509 array( 469 510 'post_mime_type' => 'image/jpeg', 470 511 'post_excerpt' => 'A sample caption', … … 481 522 public function test_get_item_sizes() { 482 523 $attachment_id = $this->factory->attachment->create_object( 483 $this->test_file, 0, array( 484 'post_mime_type' => 'image/jpeg', 485 'post_excerpt' => 'A sample caption', 486 ), $this->test_file 524 $this->test_file, 525 0, 526 array( 527 'post_mime_type' => 'image/jpeg', 528 'post_excerpt' => 'A sample caption', 529 ), 530 $this->test_file 487 531 ); 488 532 … … 505 549 public function test_get_item_sizes_with_no_url() { 506 550 $attachment_id = $this->factory->attachment->create_object( 507 $this->test_file, 0, array( 508 'post_mime_type' => 'image/jpeg', 509 'post_excerpt' => 'A sample caption', 510 ), $this->test_file 551 $this->test_file, 552 0, 553 array( 554 'post_mime_type' => 'image/jpeg', 555 'post_excerpt' => 'A sample caption', 556 ), 557 $this->test_file 511 558 ); 512 559 … … 529 576 $draft_post = $this->factory->post->create( array( 'post_status' => 'draft' ) ); 530 577 $id1 = $this->factory->attachment->create_object( 531 $this->test_file, $draft_post, array( 578 $this->test_file, 579 $draft_post, 580 array( 532 581 'post_mime_type' => 'image/jpeg', 533 582 'post_excerpt' => 'A sample caption', … … 541 590 public function test_get_item_inherit_status_with_invalid_parent() { 542 591 $attachment_id = $this->factory->attachment->create_object( 543 $this->test_file, REST_TESTS_IMPOSSIBLY_HIGH_NUMBER, array( 592 $this->test_file, 593 REST_TESTS_IMPOSSIBLY_HIGH_NUMBER, 594 array( 544 595 'post_mime_type' => 'image/jpeg', 545 596 'post_excerpt' => 'A sample caption', … … 556 607 public function test_get_item_auto_status_with_invalid_parent_not_authenticated_returns_error() { 557 608 $attachment_id = $this->factory->attachment->create_object( 558 $this->test_file, REST_TESTS_IMPOSSIBLY_HIGH_NUMBER, array( 609 $this->test_file, 610 REST_TESTS_IMPOSSIBLY_HIGH_NUMBER, 611 array( 559 612 'post_mime_type' => 'image/jpeg', 560 613 'post_excerpt' => 'A sample caption', … … 791 844 wp_set_current_user( self::$editor_id ); 792 845 $attachment_id = $this->factory->attachment->create_object( 793 $this->test_file, 0, array( 846 $this->test_file, 847 0, 848 array( 794 849 'post_mime_type' => 'image/jpeg', 795 850 'post_excerpt' => 'A sample caption', … … 819 874 $original_parent = $this->factory->post->create( array() ); 820 875 $attachment_id = $this->factory->attachment->create_object( 821 $this->test_file, $original_parent, array( 876 $this->test_file, 877 $original_parent, 878 array( 822 879 'post_mime_type' => 'image/jpeg', 823 880 'post_excerpt' => 'A sample caption', … … 841 898 wp_set_current_user( self::$author_id ); 842 899 $attachment_id = $this->factory->attachment->create_object( 843 $this->test_file, 0, array( 900 $this->test_file, 901 0, 902 array( 844 903 'post_mime_type' => 'image/jpeg', 845 904 'post_excerpt' => 'A sample caption', … … 863 922 wp_set_current_user( self::$editor_id ); 864 923 $attachment_id = $this->factory->attachment->create_object( 865 $this->test_file, 0, array( 924 $this->test_file, 925 0, 926 array( 866 927 'post_mime_type' => 'image/jpeg', 867 928 'post_excerpt' => 'A sample caption', … … 1060 1121 'description' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>', 1061 1122 'caption' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>', 1062 ), array( 1123 ), 1124 array( 1063 1125 'title' => array( 1064 1126 'raw' => 'div <strong>strong</strong> oh noes', … … 1082 1144 'description' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>', 1083 1145 'caption' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>', 1084 ), array( 1146 ), 1147 array( 1085 1148 'title' => array( 1086 1149 'raw' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>', … … 1108 1171 'description' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>', 1109 1172 'caption' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>', 1110 ), array( 1173 ), 1174 array( 1111 1175 'title' => array( 1112 1176 'raw' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>', … … 1128 1192 wp_set_current_user( self::$editor_id ); 1129 1193 $attachment_id = $this->factory->attachment->create_object( 1130 $this->test_file, 0, array( 1194 $this->test_file, 1195 0, 1196 array( 1131 1197 'post_mime_type' => 'image/jpeg', 1132 1198 'post_excerpt' => 'A sample caption', … … 1142 1208 wp_set_current_user( self::$editor_id ); 1143 1209 $attachment_id = $this->factory->attachment->create_object( 1144 $this->test_file, 0, array( 1210 $this->test_file, 1211 0, 1212 array( 1145 1213 'post_mime_type' => 'image/jpeg', 1146 1214 'post_excerpt' => 'A sample caption', … … 1165 1233 wp_set_current_user( self::$author_id ); 1166 1234 $attachment_id = $this->factory->attachment->create_object( 1167 $this->test_file, 0, array( 1235 $this->test_file, 1236 0, 1237 array( 1168 1238 'post_mime_type' => 'image/jpeg', 1169 1239 'post_excerpt' => 'A sample caption', … … 1178 1248 public function test_prepare_item() { 1179 1249 $attachment_id = $this->factory->attachment->create_object( 1180 $this->test_file, 0, array( 1250 $this->test_file, 1251 0, 1252 array( 1181 1253 'post_mime_type' => 'image/jpeg', 1182 1254 'post_excerpt' => 'A sample caption', … … 1195 1267 public function test_prepare_item_limit_fields() { 1196 1268 $attachment_id = $this->factory->attachment->create_object( 1197 $this->test_file, 0, array( 1269 $this->test_file, 1270 0, 1271 array( 1198 1272 'post_mime_type' => 'image/jpeg', 1199 1273 'post_excerpt' => 'A sample caption', … … 1208 1282 $obj = get_post( $attachment_id ); 1209 1283 $response = $endpoint->prepare_item_for_response( $obj, $request ); 1210 $this->assertEquals( array( 1211 'id', 1212 'slug', 1213 ), array_keys( $response->get_data() ) ); 1284 $this->assertEquals( 1285 array( 1286 'id', 1287 'slug', 1288 ), 1289 array_keys( $response->get_data() ) 1290 ); 1214 1291 } 1215 1292 … … 1262 1339 1263 1340 register_rest_field( 1264 'attachment', 'my_custom_int', array( 1341 'attachment', 1342 'my_custom_int', 1343 array( 1265 1344 'schema' => $schema, 1266 1345 'get_callback' => array( $this, 'additional_field_get_callback' ), … … 1276 1355 1277 1356 $attachment_id = $this->factory->attachment->create_object( 1278 $this->test_file, 0, array( 1357 $this->test_file, 1358 0, 1359 array( 1279 1360 'post_mime_type' => 'image/jpeg', 1280 1361 'post_excerpt' => 'A sample caption', … … 1300 1381 1301 1382 register_rest_field( 1302 'attachment', 'my_custom_int', array( 1383 'attachment', 1384 'my_custom_int', 1385 array( 1303 1386 'schema' => $schema, 1304 1387 'get_callback' => array( $this, 'additional_field_get_callback' ), … … 1309 1392 wp_set_current_user( self::$editor_id ); 1310 1393 $attachment_id = $this->factory->attachment->create_object( 1311 $this->test_file, 0, array( 1394 $this->test_file, 1395 0, 1396 array( 1312 1397 'post_mime_type' => 'image/jpeg', 1313 1398 'post_excerpt' => 'A sample caption', … … 1333 1418 public function test_search_item_by_filename() { 1334 1419 $id = $this->factory->attachment->create_object( 1335 $this->test_file, 0, array( 1420 $this->test_file, 1421 0, 1422 array( 1336 1423 'post_mime_type' => 'image/jpeg', 1337 1424 ) 1338 1425 ); 1339 1426 $id2 = $this->factory->attachment->create_object( 1340 $this->test_file2, 0, array( 1427 $this->test_file2, 1428 0, 1429 array( 1341 1430 'post_mime_type' => 'image/png', 1342 1431 )
Note: See TracChangeset
for help on using the changeset viewer.