- Timestamp:
- 01/27/2024 12:05:24 AM (8 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/wpRestTemplatesController.php
r56421 r57366 103 103 $this->assertSame( 104 104 array( 105 'id' => 'default//my_template',106 'theme' => 'default',107 'slug' => 'my_template',108 'source' => 'custom',109 'origin' => null,110 'type' => 'wp_template',111 'description' => 'Description of my template.',112 'title' => array(105 'id' => 'default//my_template', 106 'theme' => 'default', 107 'slug' => 'my_template', 108 'source' => 'custom', 109 'origin' => null, 110 'type' => 'wp_template', 111 'description' => 'Description of my template.', 112 'title' => array( 113 113 'raw' => 'My Template', 114 114 'rendered' => 'My Template', 115 115 ), 116 'status' => 'publish', 117 'wp_id' => self::$post->ID, 118 'has_theme_file' => false, 119 'is_custom' => true, 120 'author' => 0, 121 'modified' => mysql_to_rfc3339( self::$post->post_modified ), 116 'status' => 'publish', 117 'wp_id' => self::$post->ID, 118 'has_theme_file' => false, 119 'is_custom' => true, 120 'author' => 0, 121 'modified' => mysql_to_rfc3339( self::$post->post_modified ), 122 'author_text' => 'Test Blog', 123 'original_source' => 'site', 122 124 ), 123 125 $this->find_and_normalize_template_by_id( $data, 'default//my_template' ) … … 148 150 $this->assertSame( 149 151 array( 150 'id' => 'default//my_template',151 'theme' => 'default',152 'slug' => 'my_template',153 'source' => 'custom',154 'origin' => null,155 'type' => 'wp_template',156 'description' => 'Description of my template.',157 'title' => array(152 'id' => 'default//my_template', 153 'theme' => 'default', 154 'slug' => 'my_template', 155 'source' => 'custom', 156 'origin' => null, 157 'type' => 'wp_template', 158 'description' => 'Description of my template.', 159 'title' => array( 158 160 'raw' => 'My Template', 159 161 'rendered' => 'My Template', 160 162 ), 161 'status' => 'publish', 162 'wp_id' => self::$post->ID, 163 'has_theme_file' => false, 164 'is_custom' => true, 165 'author' => 0, 166 'modified' => mysql_to_rfc3339( self::$post->post_modified ), 163 'status' => 'publish', 164 'wp_id' => self::$post->ID, 165 'has_theme_file' => false, 166 'is_custom' => true, 167 'author' => 0, 168 'modified' => mysql_to_rfc3339( self::$post->post_modified ), 169 'author_text' => 'Test Blog', 170 'original_source' => 'site', 167 171 ), 168 172 $data … … 185 189 $this->assertSame( 186 190 array( 187 'id' => 'default//my_template',188 'theme' => 'default',189 'slug' => 'my_template',190 'source' => 'custom',191 'origin' => null,192 'type' => 'wp_template',193 'description' => 'Description of my template.',194 'title' => array(191 'id' => 'default//my_template', 192 'theme' => 'default', 193 'slug' => 'my_template', 194 'source' => 'custom', 195 'origin' => null, 196 'type' => 'wp_template', 197 'description' => 'Description of my template.', 198 'title' => array( 195 199 'raw' => 'My Template', 196 200 'rendered' => 'My Template', 197 201 ), 198 'status' => 'publish', 199 'wp_id' => self::$post->ID, 200 'has_theme_file' => false, 201 'is_custom' => true, 202 'author' => 0, 203 'modified' => mysql_to_rfc3339( self::$post->post_modified ), 202 'status' => 'publish', 203 'wp_id' => self::$post->ID, 204 'has_theme_file' => false, 205 'is_custom' => true, 206 'author' => 0, 207 'modified' => mysql_to_rfc3339( self::$post->post_modified ), 208 'author_text' => 'Test Blog', 209 'original_source' => 'site', 204 210 ), 205 211 $data … … 242 248 unset( $data['content'] ); 243 249 unset( $data['_links'] ); 250 $author_name = get_user_by( 'id', self::$admin_id )->get( 'display_name' ); 244 251 245 252 $this->assertSameSetsWithIndex( 246 253 array( 247 'id' => "{$theme_dir}//{$template}",248 'theme' => $theme_dir,249 'slug' => $template,250 'source' => 'custom',251 'origin' => null,252 'type' => 'wp_template',253 'description' => $args['post_excerpt'],254 'title' => array(254 'id' => "{$theme_dir}//{$template}", 255 'theme' => $theme_dir, 256 'slug' => $template, 257 'source' => 'custom', 258 'origin' => null, 259 'type' => 'wp_template', 260 'description' => $args['post_excerpt'], 261 'title' => array( 255 262 'raw' => $args['post_title'], 256 263 'rendered' => $args['post_title'], 257 264 ), 258 'status' => 'publish', 259 'wp_id' => $post->ID, 260 'has_theme_file' => false, 261 'is_custom' => true, 262 'author' => self::$admin_id, 263 'modified' => mysql_to_rfc3339( $post->post_modified ), 265 'status' => 'publish', 266 'wp_id' => $post->ID, 267 'has_theme_file' => false, 268 'is_custom' => true, 269 'author' => self::$admin_id, 270 'modified' => mysql_to_rfc3339( $post->post_modified ), 271 'author_text' => $author_name, 272 'original_source' => 'user', 264 273 ), 265 274 $data … … 422 431 unset( $data['wp_id'] ); 423 432 433 $author_name = get_user_by( 'id', self::$admin_id )->get( 'display_name' ); 434 424 435 $this->assertSame( 425 436 array( 426 'id' => 'default//my_custom_template',427 'theme' => 'default',428 'content' => array(437 'id' => 'default//my_custom_template', 438 'theme' => 'default', 439 'content' => array( 429 440 'raw' => 'Content', 430 441 ), 431 'slug' => 'my_custom_template',432 'source' => 'custom',433 'origin' => null,434 'type' => 'wp_template',435 'description' => 'Just a description',436 'title' => array(442 'slug' => 'my_custom_template', 443 'source' => 'custom', 444 'origin' => null, 445 'type' => 'wp_template', 446 'description' => 'Just a description', 447 'title' => array( 437 448 'raw' => 'My Template', 438 449 'rendered' => 'My Template', 439 450 ), 440 'status' => 'publish', 441 'has_theme_file' => false, 442 'is_custom' => true, 443 'author' => self::$admin_id, 444 'modified' => mysql_to_rfc3339( $modified ), 451 'status' => 'publish', 452 'has_theme_file' => false, 453 'is_custom' => true, 454 'author' => self::$admin_id, 455 'modified' => mysql_to_rfc3339( $modified ), 456 'author_text' => $author_name, 457 'original_source' => 'user', 445 458 ), 446 459 $data … … 470 483 unset( $data['wp_id'] ); 471 484 485 $author_name = get_user_by( 'id', self::$admin_id )->get( 'display_name' ); 486 472 487 $this->assertSame( 473 488 array( 474 'id' => 'default//404',475 'theme' => 'default',476 'content' => array(489 'id' => 'default//404', 490 'theme' => 'default', 491 'content' => array( 477 492 'raw' => '', 478 493 ), 479 'slug' => '404',480 'source' => 'custom',481 'origin' => null,482 'type' => 'wp_template',483 'description' => 'Template shown when no content is found.',484 'title' => array(494 'slug' => '404', 495 'source' => 'custom', 496 'origin' => null, 497 'type' => 'wp_template', 498 'description' => 'Template shown when no content is found.', 499 'title' => array( 485 500 'raw' => '404', 486 501 'rendered' => '404', 487 502 ), 488 'status' => 'publish', 489 'has_theme_file' => false, 490 'is_custom' => false, 491 'author' => self::$admin_id, 492 'modified' => mysql_to_rfc3339( $modified ), 503 'status' => 'publish', 504 'has_theme_file' => false, 505 'is_custom' => false, 506 'author' => self::$admin_id, 507 'modified' => mysql_to_rfc3339( $modified ), 508 'author_text' => $author_name, 509 'original_source' => 'user', 493 510 ), 494 511 $data … … 522 539 unset( $data['wp_id'] ); 523 540 541 $author_name = get_user_by( 'id', self::$admin_id )->get( 'display_name' ); 542 524 543 $this->assertSame( 525 544 array( 526 'id' => 'default//my_custom_template_raw',527 'theme' => 'default',528 'content' => array(545 'id' => 'default//my_custom_template_raw', 546 'theme' => 'default', 547 'content' => array( 529 548 'raw' => 'Content', 530 549 ), 531 'slug' => 'my_custom_template_raw',532 'source' => 'custom',533 'origin' => null,534 'type' => 'wp_template',535 'description' => 'Just a description',536 'title' => array(550 'slug' => 'my_custom_template_raw', 551 'source' => 'custom', 552 'origin' => null, 553 'type' => 'wp_template', 554 'description' => 'Just a description', 555 'title' => array( 537 556 'raw' => 'My Template', 538 557 'rendered' => 'My Template', 539 558 ), 540 'status' => 'publish', 541 'has_theme_file' => false, 542 'is_custom' => true, 543 'author' => self::$admin_id, 544 'modified' => mysql_to_rfc3339( $modified ), 559 'status' => 'publish', 560 'has_theme_file' => false, 561 'is_custom' => true, 562 'author' => self::$admin_id, 563 'modified' => mysql_to_rfc3339( $modified ), 564 'author_text' => $author_name, 565 'original_source' => 'user', 545 566 ), 546 567 $data … … 701 722 $data = $response->get_data(); 702 723 $properties = $data['schema']['properties']; 703 $this->assertCount( 1 5, $properties );724 $this->assertCount( 17, $properties ); 704 725 $this->assertArrayHasKey( 'id', $properties ); 705 726 $this->assertArrayHasKey( 'description', $properties ); … … 718 739 $this->assertArrayHasKey( 'author', $properties ); 719 740 $this->assertArrayHasKey( 'modified', $properties ); 741 $this->assertArrayHasKey( 'author_text', $properties ); 742 $this->assertArrayHasKey( 'original_source', $properties ); 720 743 } 721 744 … … 748 771 $request = new WP_REST_Request( 'POST', '/wp/v2/templates' ); 749 772 $request->set_body_params( $body_params ); 750 $response = rest_get_server()->dispatch( $request ); 751 $data = $response->get_data(); 752 $modified = get_post( $data['wp_id'] )->post_modified; 753 $expected['modified'] = mysql_to_rfc3339( $modified ); 773 $response = rest_get_server()->dispatch( $request ); 774 $data = $response->get_data(); 775 $modified = get_post( $data['wp_id'] )->post_modified; 776 $expected['modified'] = mysql_to_rfc3339( $modified ); 777 $expected['author_text'] = get_user_by( 'id', self::$admin_id )->get( 'display_name' ); 778 $expected['original_source'] = 'user'; 779 754 780 unset( $data['_links'] ); 755 781 unset( $data['wp_id'] );
Note: See TracChangeset
for help on using the changeset viewer.