Changeset 57686 for trunk/tests/phpunit/tests/fonts/font-library/wpRestFontCollectionsController.php
- Timestamp:
- 02/21/2024 07:24:14 PM (9 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/fonts/font-library/wpRestFontCollectionsController.php
r57548 r57686 39 39 file_put_contents( $mock_file, '{"name": "Mock Collection", "font_families": [ "mock" ], "categories": [ "mock" ] }' ); 40 40 41 wp_register_font_collection( 'mock-col-slug', $mock_file ); 41 wp_register_font_collection( 42 'mock-col-slug', 43 array( 44 'name' => 'My collection', 45 'font_families' => $mock_file, 46 ) 47 ); 42 48 } 43 49 … … 79 85 80 86 wp_set_current_user( self::$admin_id ); 81 wp_register_font_collection( 'invalid-collection', 'invalid-collection-file' ); 87 wp_register_font_collection( 88 'invalid-collection', 89 array( 90 'name' => 'My collection', 91 'font_families' => 'invalid-collection-file', 92 ) 93 ); 82 94 83 95 $request = new WP_REST_Request( 'GET', '/wp/v2/font-collections' ); … … 133 145 wp_set_current_user( self::$admin_id ); 134 146 $slug = 'invalid-collection'; 135 wp_register_font_collection( $slug, 'invalid-collection-file' ); 147 wp_register_font_collection( 148 $slug, 149 array( 150 'name' => 'My collection', 151 'font_families' => 'invalid-collection-file', 152 ) 153 ); 136 154 137 155 $request = new WP_REST_Request( 'GET', '/wp/v2/font-collections/' . $slug ); … … 140 158 wp_unregister_font_collection( $slug ); 141 159 142 $this->assertErrorResponse( 'font_collection_json_missing', $response, 500 , 'When the collection json file is invalid, the response should return an error for "font_collection_json_missing" with 500 status.');160 $this->assertErrorResponse( 'font_collection_json_missing', $response, 500 ); 143 161 } 144 162 … … 151 169 wp_set_current_user( 0 ); 152 170 $response = rest_get_server()->dispatch( $request ); 153 $this->assertErrorResponse( 'rest_cannot_read', $response, 401 , 'The response status should be 401 for non-authenticated users.');171 $this->assertErrorResponse( 'rest_cannot_read', $response, 401 ); 154 172 155 173 wp_set_current_user( self::$editor_id ); 156 174 $response = rest_get_server()->dispatch( $request ); 157 $this->assertErrorResponse( 'rest_cannot_read', $response, 403 , 'The response status should be 403 for users without the right permissions.');175 $this->assertErrorResponse( 'rest_cannot_read', $response, 403 ); 158 176 } 159 177
Note: See TracChangeset
for help on using the changeset viewer.