- Timestamp:
- 06/02/2024 07:25:03 PM (10 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-themes-controller.php
r57987 r58282 163 163 * 164 164 * @ticket 45016 165 * @ticket 61021 165 166 */ 166 167 public function test_get_items() { … … 183 184 'status', 184 185 'stylesheet', 186 'stylesheet_uri', 185 187 'tags', 186 188 'template', 189 'template_uri', 187 190 'textdomain', 188 191 'theme_supports', … … 199 202 * 200 203 * @ticket 50152 204 * @ticket 61021 201 205 */ 202 206 public function test_get_items_inactive() { … … 222 226 'status', 223 227 'stylesheet', 228 'stylesheet_uri', 224 229 'tags', 225 230 'template', 231 'template_uri', 226 232 'textdomain', 227 233 'theme_uri', … … 348 354 * 349 355 * @ticket 45016 356 * @ticket 61021 350 357 */ 351 358 public function test_get_item_schema() { … … 353 360 $data = $response->get_data(); 354 361 $properties = $data['schema']['properties']; 355 $this->assertCount( 1 6, $properties );362 $this->assertCount( 18, $properties ); 356 363 357 364 $this->assertArrayHasKey( 'author', $properties ); … … 378 385 $this->assertArrayHasKey( 'status', $properties ); 379 386 $this->assertArrayHasKey( 'stylesheet', $properties ); 387 $this->assertArrayHasKey( 'stylesheet_uri', $properties ); 380 388 381 389 $this->assertArrayHasKey( 'tags', $properties ); … … 385 393 386 394 $this->assertArrayHasKey( 'template', $properties ); 395 $this->assertArrayHasKey( 'template_uri', $properties ); 387 396 $this->assertArrayHasKey( 'textdomain', $properties ); 388 397 $this->assertArrayHasKey( 'theme_supports', $properties ); … … 536 545 537 546 /** 547 * @ticket 61021 548 */ 549 public function test_theme_stylesheet_uri() { 550 wp_set_current_user( self::$admin_id ); 551 $request = new WP_REST_Request( 'GET', self::$themes_route ); 552 $request->set_param( 'status', array( 'active', 'inactive' ) ); 553 554 $response = rest_get_server()->dispatch( $request ); 555 $result = $response->get_data(); 556 $current_theme = wp_get_theme(); 557 558 foreach ( $result as $theme_result ) { 559 $this->assertArrayHasKey( 'stylesheet_uri', $theme_result ); 560 if ( 'active' === $theme_result['status'] ) { 561 $this->assertSame( 562 get_stylesheet_directory_uri(), 563 $theme_result['stylesheet_uri'], 564 'stylesheet_uri for an active theme should be the same as the global get_stylesheet_directory_uri()' 565 ); 566 } else { 567 $theme = wp_get_theme( $theme_result['stylesheet'] ); 568 $this->assertSame( 569 $theme->get_stylesheet_directory_uri(), 570 $theme_result['stylesheet_uri'], 571 "stylesheet_uri for an inactive theme should be the same as the theme's get_stylesheet_directory_uri() method" 572 ); 573 } 574 } 575 } 576 577 /** 538 578 * @ticket 49906 539 579 */ … … 554 594 $this->assertArrayHasKey( 'template', $result[0] ); 555 595 $this->assertSame( 'default', $result[0]['template'] ); 596 } 597 598 /** 599 * @ticket 61021 600 */ 601 public function test_theme_template_uri() { 602 wp_set_current_user( self::$admin_id ); 603 $request = new WP_REST_Request( 'GET', self::$themes_route ); 604 $request->set_param( 'status', array( 'active', 'inactive' ) ); 605 606 $response = rest_get_server()->dispatch( $request ); 607 $result = $response->get_data(); 608 $current_theme = wp_get_theme(); 609 610 foreach ( $result as $theme_result ) { 611 $this->assertArrayHasKey( 'template_uri', $theme_result ); 612 if ( 'active' === $theme_result['status'] ) { 613 $this->assertSame( 614 get_template_directory_uri(), 615 $theme_result['template_uri'], 616 'template_uri for an active theme should be the same as the global get_template_directory_uri()' 617 ); 618 } else { 619 $theme = wp_get_theme( $theme_result['stylesheet'] ); 620 $this->assertSame( 621 $theme->get_template_directory_uri(), 622 $theme_result['template_uri'], 623 "template_uri for an inactive theme should be the same as the theme's get_template_directory_uri() method" 624 ); 625 } 626 } 556 627 } 557 628 … … 1274 1345 'status', 1275 1346 'stylesheet', 1347 'stylesheet_uri', 1276 1348 'tags', 1277 1349 'template', 1350 'template_uri', 1278 1351 'textdomain', 1279 1352 'theme_uri',
Note: See TracChangeset
for help on using the changeset viewer.