summaryrefslogtreecommitdiffstatshomepage
path: root/tests
diff options
context:
space:
mode:
authorGeorge Mamadashvili <mamaduka@git.wordpress.org>2025-03-11 06:13:47 +0000
committerGeorge Mamadashvili <mamaduka@git.wordpress.org>2025-03-11 06:13:47 +0000
commit5564c705b1e0827563a1fb4ec38377105782cdfd (patch)
tree006b928e6bc1faaa740e990a5de846977b344f20 /tests
parent07e3b258b5f111f2d3d5d093f929bbd040ac19b9 (diff)
downloadwordpress-5564c705b1e0827563a1fb4ec38377105782cdfd.tar.gz
wordpress-5564c705b1e0827563a1fb4ec38377105782cdfd.zip
REST API: Add additional default template data fields for the active theme.
The active theme(s) now return two additional properties, `default_template_types` and `default_template_part_areas`, in the REST response. Props mamaduka, joemcgill, timothyblynjacobs, audrasjb, gigitux, peterwilsoncc, youknowriad, jorbin. Fixes #62574. git-svn-id: https://develop.svn.wordpress.org/trunk@59965 602fd350-edb4-49c9-b593-d223f7449a82
Diffstat (limited to 'tests')
-rw-r--r--tests/phpunit/tests/rest-api/rest-themes-controller.php35
1 files changed, 34 insertions, 1 deletions
diff --git a/tests/phpunit/tests/rest-api/rest-themes-controller.php b/tests/phpunit/tests/rest-api/rest-themes-controller.php
index d1ebb5b8ba..923e7cda27 100644
--- a/tests/phpunit/tests/rest-api/rest-themes-controller.php
+++ b/tests/phpunit/tests/rest-api/rest-themes-controller.php
@@ -163,6 +163,7 @@ class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase {
*
* @ticket 45016
* @ticket 61021
+ * @ticket 62574.
*/
public function test_get_items() {
$response = self::perform_active_theme_request();
@@ -175,6 +176,8 @@ class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase {
'_links',
'author',
'author_uri',
+ 'default_template_part_areas',
+ 'default_template_types',
'description',
'is_block_theme',
'name',
@@ -354,12 +357,13 @@ class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase {
*
* @ticket 45016
* @ticket 61021
+ * @ticket 62574
*/
public function test_get_item_schema() {
$response = self::perform_active_theme_request( 'OPTIONS' );
$data = $response->get_data();
$properties = $data['schema']['properties'];
- $this->assertCount( 18, $properties );
+ $this->assertCount( 20, $properties );
$this->assertArrayHasKey( 'author', $properties );
$this->assertArrayHasKey( 'raw', $properties['author']['properties'] );
@@ -373,6 +377,9 @@ class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase {
$this->assertArrayHasKey( 'raw', $properties['description']['properties'] );
$this->assertArrayHasKey( 'rendered', $properties['description']['properties'] );
+ $this->assertArrayHasKey( 'default_template_part_areas', $properties );
+ $this->assertArrayHasKey( 'default_template_types', $properties );
+
$this->assertArrayHasKey( 'is_block_theme', $properties );
$this->assertArrayHasKey( 'name', $properties );
@@ -473,6 +480,32 @@ class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase {
}
/**
+ * @ticket 62574
+ */
+ public function test_theme_default_template_part_areas() {
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $this->assertArrayHasKey( 'default_template_part_areas', $result[0] );
+ $this->assertSame( get_allowed_block_template_part_areas(), $result[0]['default_template_part_areas'] );
+ }
+
+ /**
+ * @ticket 62574
+ */
+ public function test_theme_default_template_types() {
+ $response = self::perform_active_theme_request();
+ $result = $response->get_data();
+ $expected = array();
+ foreach ( get_default_block_template_types() as $slug => $template_type ) {
+ $template_type['slug'] = (string) $slug;
+ $expected[] = $template_type;
+ }
+
+ $this->assertArrayHasKey( 'default_template_types', $result[0] );
+ $this->assertSame( $expected, $result[0]['default_template_types'] );
+ }
+
+ /**
* @ticket 49906
*/
public function test_theme_requires_php() {