- Timestamp:
- 05/31/2024 01:17:50 AM (9 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-global-styles-controller.php
r57662 r58262 35 35 parent::set_up(); 36 36 switch_theme( 'tt1-blocks' ); 37 add_filter( 'theme_file_uri', array( $this, 'filter_theme_file_uri' ) ); 38 } 39 40 public function tear_down() { 41 remove_filter( 'theme_file_uri', array( $this, 'filter_theme_file_uri' ) ); 42 parent::tear_down(); 37 43 } 38 44 … … 80 86 } 81 87 88 /* 89 * This filter callback normalizes the return value from `get_theme_file_uri` 90 * to guard against changes in test environments. 91 * The test suite otherwise returns full system dir path, e.g., 92 * /var/www/tests/phpunit/includes/../data/themedir1/block-theme/assets/sugarloaf-mountain.jpg 93 */ 94 public function filter_theme_file_uri( $file ) { 95 $file_name = substr( strrchr( $file, '/' ), 1 ); 96 return 'https://example.org/wp-content/themes/example-theme/assets/' . $file_name; 97 } 98 82 99 /** 83 100 * @covers WP_REST_Global_Styles_Controller::register_routes … … 120 137 } 121 138 139 /** 140 * Tests a GET request to the global styles variations endpoint. 141 * 142 * @covers WP_REST_Global_Styles_Controller::get_theme_items 143 * @ticket 61273 144 */ 122 145 public function test_get_theme_items() { 123 146 wp_set_current_user( self::$admin_id ); … … 129 152 array( 130 153 'version' => 2, 131 'title' => 'variation-a',132 154 'settings' => array( 133 155 'blocks' => array( … … 147 169 ), 148 170 ), 171 'title' => 'variation-a', 149 172 ), 150 173 array( 151 174 'version' => 2, 152 'title' => 'variation-b',153 175 'settings' => array( 154 176 'blocks' => array( … … 165 187 ), 166 188 ), 189 ), 190 ), 191 ), 192 'styles' => array( 193 'background' => array( 194 'backgroundImage' => array( 195 'url' => 'file:./assets/sugarloaf-mountain.jpg', 196 ), 197 ), 198 ), 199 'title' => 'variation-b', 200 '_links' => array( 201 'curies' => array( 202 array( 203 'name' => 'wp', 204 'href' => 'https://api.w.org/{rel}', 205 'templated' => true, 206 ), 207 ), 208 'wp:theme-file' => array( 209 array( 210 'href' => 'https://example.org/wp-content/themes/example-theme/assets/sugarloaf-mountain.jpg', 211 'name' => 'file:./assets/sugarloaf-mountain.jpg', 212 'target' => 'styles.background.backgroundImage.url', 213 'type' => 'image/jpeg', 167 214 ), 168 215 ),
Note: See TracChangeset
for help on using the changeset viewer.