- Timestamp:
- 12/21/2021 04:12:06 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-themes-controller.php
r52017 r52399 1286 1286 1287 1287 /** 1288 * @dataProvider data_get_item_non_subdir_theme 1289 * @ticket 54596 1290 * @covers WP_REST_Themes_Controller::get_item 1291 * 1292 * @param string $theme_dir Theme directory to test. 1293 * @param string $expected_name Expected theme name. 1294 */ 1295 public function test_get_item_non_subdir_theme( $theme_dir, $expected_name ) { 1296 wp_set_current_user( self::$admin_id ); 1297 $request = new WP_REST_Request( 'GET', self::$themes_route . $theme_dir ); 1298 $response = rest_do_request( $request ); 1299 1300 $this->assertSame( 200, $response->get_status() ); 1301 $this->assertSame( $expected_name, $response->get_data()['name']['raw'] ); 1302 } 1303 1304 /** 1305 * Data provider. 1306 * 1307 * @return array 1308 */ 1309 public function data_get_item_non_subdir_theme() { 1310 return array( 1311 'parent theme' => array( 1312 'theme_dir' => '/block-theme', 1313 'expected_name' => 'Block Theme', 1314 ), 1315 'child theme' => array( 1316 'theme_dir' => '/block-theme-child', 1317 'expected_name' => 'Block Theme Child Theme', 1318 ), 1319 'theme with _-[]. characters' => array( 1320 'theme_dir' => '/block_theme-[0.4.0]', 1321 'expected_name' => 'Block Theme [0.4.0]', 1322 ), 1323 ); 1324 } 1325 1326 /** 1327 * @dataProvider data_get_item_subdirectory_theme 1288 1328 * @ticket 54349 1289 */ 1290 public function test_get_item_subdirectory_theme() { 1329 * @ticket 54596 1330 * @covers WP_REST_Themes_Controller::get_item 1331 * 1332 * @param string $theme_dir Theme directory to test. 1333 * @param string $expected_name Expected theme name. 1334 */ 1335 public function test_get_item_subdirectory_theme( $theme_dir, $expected_name ) { 1291 1336 wp_set_current_user( self::$admin_id ); 1292 $request = new WP_REST_Request( 'GET', self::$themes_route . '/subdir/theme2');1337 $request = new WP_REST_Request( 'GET', self::$themes_route . $theme_dir ); 1293 1338 $response = rest_do_request( $request ); 1294 1339 1295 $this->assertSame( 200, $response->get_status() ); 1296 $this->assertSame( 'My Subdir Theme', $response->get_data()['name']['raw'] ); 1340 $this->assertSame( 1341 200, 1342 $response->get_status(), 1343 'A 200 OK status was not returned.' 1344 ); 1345 $this->assertSame( 1346 $expected_name, 1347 $response->get_data()['name']['raw'], 1348 'The actual theme name was not the expected theme name.' 1349 ); 1350 } 1351 1352 /** 1353 * Data provider. 1354 * 1355 * @return array 1356 */ 1357 public function data_get_item_subdirectory_theme() { 1358 return array( 1359 'theme2' => array( 1360 'theme_dir' => '/subdir/theme2', 1361 'expected_name' => 'My Subdir Theme', 1362 ), 1363 'theme with _-[]. characters' => array( 1364 'theme_dir' => '/subdir/block_theme-[1.0.0]', 1365 'expected_name' => 'Block Theme [1.0.0] in subdirectory', 1366 ), 1367 ); 1297 1368 } 1298 1369
Note: See TracChangeset
for help on using the changeset viewer.