- Timestamp:
- 06/27/2025 08:45:08 PM (15 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-global-styles-controller.php
r59048 r60359 134 134 $routes = rest_get_server()->get_routes(); 135 135 $this->assertArrayHasKey( 136 '/wp/v2/global-styles/(?P<id>[\/\ w-]+)',136 '/wp/v2/global-styles/(?P<id>[\/\d+]+)', 137 137 $routes, 138 138 'Single global style based on the given ID route does not exist' … … 140 140 $this->assertCount( 141 141 2, 142 $routes['/wp/v2/global-styles/(?P<id>[\/\ w-]+)'],142 $routes['/wp/v2/global-styles/(?P<id>[\/\d+]+)'], 143 143 'Single global style based on the given ID route does not have exactly two elements' 144 144 ); … … 409 409 '2 subdirectories deep' => array( 410 410 'theme_dirname' => 'subdir/subsubdir/mytheme', 411 'expected' => 'rest_ global_styles_not_found',411 'expected' => 'rest_no_route', 412 412 ), 413 413 ); … … 777 777 } 778 778 } 779 780 /** 781 * Test that the route accepts integer IDs. 782 * 783 * @ticket 61911 784 */ 785 public function test_global_styles_route_accepts_integer_id() { 786 wp_set_current_user( self::$admin_id ); 787 $request = new WP_REST_Request( 'GET', '/wp/v2/global-styles/' . self::$global_styles_id ); 788 $response = rest_get_server()->dispatch( $request ); 789 790 $this->assertEquals( 200, $response->get_status() ); 791 792 $data = $response->get_data(); 793 $this->assertIsInt( $data['id'] ); 794 $this->assertSame( self::$global_styles_id, $data['id'] ); 795 } 796 797 /** 798 * Test that the schema defines ID as an integer. 799 * 800 * @ticket 61911 801 */ 802 public function test_global_styles_schema_id_type() { 803 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/global-styles/' . self::$global_styles_id ); 804 $response = rest_get_server()->dispatch( $request ); 805 806 $data = $response->get_data(); 807 $schema = $data['schema']; 808 809 $this->assertArrayHasKey( 'properties', $schema ); 810 $this->assertArrayHasKey( 'id', $schema['properties'] ); 811 $this->assertArrayHasKey( 'type', $schema['properties']['id'] ); 812 $this->assertSame( 'integer', $schema['properties']['id']['type'] ); 813 } 814 815 /** 816 * Test that the route argument schema defines ID as an integer. 817 * 818 * @ticket 61911 819 */ 820 public function test_global_styles_route_args_schema() { 821 $routes = rest_get_server()->get_routes(); 822 $route_data = $routes['/wp/v2/global-styles/(?P<id>[\/\d+]+)']; 823 824 $this->assertArrayHasKey( 'args', $route_data[0] ); 825 $this->assertArrayHasKey( 'id', $route_data[0]['args'] ); 826 $this->assertArrayHasKey( 'type', $route_data[0]['args']['id'] ); 827 $this->assertSame( 'integer', $route_data[0]['args']['id']['type'] ); 828 } 779 829 }
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)