From 20e024dd2985b1002935d319127f885b5747d842 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Greg=20Zi=C3=83=C2=B3=C3=85=E2=80=9Akowski?= Date: Wed, 31 Aug 2022 10:11:30 +0000 Subject: [PATCH] Tests: Increase coverage for translations applied to theme.json Ensures that translations are correctly applied to the `title` field in the `theme.json` and all style variations located in the them inside the `styles` folder. Follow-up #55495, [53038]. See also #54336. git-svn-id: https://develop.svn.wordpress.org/trunk@54036 602fd350-edb4-49c9-b593-d223f7449a82 --- .../languages/themes/block-theme-pl_PL.mo | Bin 807 -> 970 bytes .../languages/themes/block-theme-pl_PL.po | 18 +++++-- .../block-theme/styles/variation.json | 45 +++++++++--------- .../data/themedir1/block-theme/theme.json | 5 +- .../rest-global-styles-controller.php | 2 +- .../tests/theme/wpThemeJsonResolver.php | 26 ++++++---- 6 files changed, 55 insertions(+), 41 deletions(-) diff --git a/tests/phpunit/data/languages/themes/block-theme-pl_PL.mo b/tests/phpunit/data/languages/themes/block-theme-pl_PL.mo index ff89f87f127f15528a0595e172c8c10aa9b638d1..d819be9b57e3cd4030b720d8cc397b473aa8e8bd 100644 GIT binary patch delta 392 zcmZ3^c8b0Jo)F7a1|VPuVi_O~0b*_-?g3&D*a5`+K)e%(1%UV@5UT<4Eg)6^Vn#*= z1}z}11f=DGv@ekU2gJER%m(D=Ff%Z)0_kEPEdit}fiy3Wo&@2WF)RQwKnCvw(m*|6 zzyc&enm_<#2ospazyMSNb|}NdRv+)+lFFP^g|ft=%*2w+{5*xc#N1RCr=0xcY=x4H z)ZA1CLJAOiCtmOtGSW4$&^0zxFf_C>u+TOzGBB9DnMrxF9%I(zC#=%D@091O`Am*%*N03@j73`b_p^^b#`E zH89pSG*vJ(wlXx(HZU|Wn0%TsdvYR^h?J3@iJlQxgl<57YD#8_u2W)hYC&R2hLwWe mWK$-+$&;84OkTyPG&zXbQ6TYXQ>8*)V*1gh!<)-fvl#$C!7BFv diff --git a/tests/phpunit/data/languages/themes/block-theme-pl_PL.po b/tests/phpunit/data/languages/themes/block-theme-pl_PL.po index 0aa4bbd52d..6ac5a6967e 100644 --- a/tests/phpunit/data/languages/themes/block-theme-pl_PL.po +++ b/tests/phpunit/data/languages/themes/block-theme-pl_PL.po @@ -2,22 +2,30 @@ msgid "" msgstr "" "Project-Id-Version: \n" "POT-Creation-Date: 2015-12-31 16:31+0100\n" -"PO-Revision-Date: 2021-03-15 13:10+0100\n" +"PO-Revision-Date: 2022-08-31 11:08+0200\n" +"Last-Translator: \n" +"Language-Team: \n" "Language: pl_PL\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Generator: Poedit 2.4.2\n" -"X-Poedit-Basepath: .\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Poedit 3.1.1\n" +"X-Poedit-Basepath: .\n" "X-Poedit-KeywordsList: __;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;" "_nx_noop:1,2,3c;esc_attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;" "esc_html_x:1,2c\n" "X-Textdomain-Support: yes\n" -"Last-Translator: \n" -"Language-Team: \n" "X-Poedit-SearchPath-0: .\n" +msgctxt "Style variation name" +msgid "Block theme" +msgstr "Motyw blokowy" + +msgctxt "Style variation name" +msgid "Block theme variation" +msgstr "Wariant motywu blokowego" + msgctxt "Custom template name" msgid "Homepage template" msgstr "Szablon strony głównej" diff --git a/tests/phpunit/data/themedir1/block-theme/styles/variation.json b/tests/phpunit/data/themedir1/block-theme/styles/variation.json index ad3affb115..d0f316cb45 100644 --- a/tests/phpunit/data/themedir1/block-theme/styles/variation.json +++ b/tests/phpunit/data/themedir1/block-theme/styles/variation.json @@ -1,23 +1,24 @@ { - "version": 2, - "settings": { - "color": { - "palette": [ - { - "slug": "foreground", - "color": "#3F67C6", - "name": "Foreground" - } - ] - } - }, - "styles": { - "blocks": { - "core/post-title": { - "typography": { - "fontWeight": "700" - } - } - } - } -} \ No newline at end of file + "version": 2, + "title": "Block theme variation", + "settings": { + "color": { + "palette": [ + { + "slug": "foreground", + "color": "#3F67C6", + "name": "Foreground" + } + ] + } + }, + "styles": { + "blocks": { + "core/post-title": { + "typography": { + "fontWeight": "700" + } + } + } + } +} diff --git a/tests/phpunit/data/themedir1/block-theme/theme.json b/tests/phpunit/data/themedir1/block-theme/theme.json index 38fcb1d9dd..7676d642b2 100644 --- a/tests/phpunit/data/themedir1/block-theme/theme.json +++ b/tests/phpunit/data/themedir1/block-theme/theme.json @@ -1,5 +1,6 @@ { "version": 1, + "title": "Block theme", "settings": { "color": { "palette": [ @@ -36,9 +37,7 @@ "customLineHeight": true }, "spacing": { - "units": [ - "rem" - ], + "units": ["rem"], "customPadding": true }, "blocks": { diff --git a/tests/phpunit/tests/rest-api/rest-global-styles-controller.php b/tests/phpunit/tests/rest-api/rest-global-styles-controller.php index e8756cf85d..2da5e18ab0 100644 --- a/tests/phpunit/tests/rest-api/rest-global-styles-controller.php +++ b/tests/phpunit/tests/rest-api/rest-global-styles-controller.php @@ -471,6 +471,7 @@ class WP_REST_Global_Styles_Controller_Test extends WP_Test_REST_Controller_Test $expected = array( array( 'version' => 2, + 'title' => 'Block theme variation', 'settings' => array( 'color' => array( 'palette' => array( @@ -493,7 +494,6 @@ class WP_REST_Global_Styles_Controller_Test extends WP_Test_REST_Controller_Test ), ), ), - 'title' => 'variation', ), ); $this->assertSameSetsWithIndex( $data, $expected ); diff --git a/tests/phpunit/tests/theme/wpThemeJsonResolver.php b/tests/phpunit/tests/theme/wpThemeJsonResolver.php index 287e5d8aeb..6ec69477b3 100644 --- a/tests/phpunit/tests/theme/wpThemeJsonResolver.php +++ b/tests/phpunit/tests/theme/wpThemeJsonResolver.php @@ -82,13 +82,15 @@ class Tests_Theme_wpThemeJsonResolver extends WP_UnitTestCase { load_textdomain( 'block-theme', realpath( DIR_TESTDATA . '/languages/themes/block-theme-pl_PL.mo' ) ); switch_theme( 'block-theme' ); - $actual = WP_Theme_JSON_Resolver::get_theme_data(); + $theme_data = WP_Theme_JSON_Resolver::get_theme_data(); + $style_variations = WP_Theme_JSON_Resolver::get_style_variations(); unload_textdomain( 'block-theme' ); remove_filter( 'locale', array( $this, 'filter_set_locale_to_polish' ) ); - $this->assertSame( wp_get_theme()->get( 'TextDomain' ), 'block-theme' ); - $this->assertSame( + $this->assertSame( 'block-theme', wp_get_theme()->get( 'TextDomain' ) ); + $this->assertSame( 'Motyw blokowy', $theme_data->get_data()['title'] ); + $this->assertSameSets( array( 'color' => array( 'custom' => false, @@ -150,25 +152,29 @@ class Tests_Theme_wpThemeJsonResolver extends WP_UnitTestCase { ), ), ), - $actual->get_settings() + $theme_data->get_settings() ); - $this->assertSame( - $actual->get_custom_templates(), + $this->assertSameSets( array( 'page-home' => array( 'title' => 'Szablon strony głównej', 'postTypes' => array( 'page' ), ), - ) + ), + $theme_data->get_custom_templates() ); - $this->assertSame( - $actual->get_template_parts(), + $this->assertSameSets( array( 'small-header' => array( 'title' => 'Mały nagłówek', 'area' => 'header', ), - ) + ), + $theme_data->get_template_parts() + ); + $this->assertSame( + 'Wariant motywu blokowego', + $style_variations[0]['title'] ); }