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
This commit is contained in:
Greg Ziółkowski 2022-08-31 10:11:30 +00:00
parent 21ebdbcb74
commit 20e024dd29
6 changed files with 55 additions and 41 deletions

View File

@ -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"

View File

@ -1,23 +1,24 @@
{
"version": 2,
"settings": {
"color": {
"palette": [
{
"slug": "foreground",
"color": "#3F67C6",
"name": "Foreground"
}
]
}
},
"styles": {
"blocks": {
"core/post-title": {
"typography": {
"fontWeight": "700"
}
}
}
}
}
"version": 2,
"title": "Block theme variation",
"settings": {
"color": {
"palette": [
{
"slug": "foreground",
"color": "#3F67C6",
"name": "Foreground"
}
]
}
},
"styles": {
"blocks": {
"core/post-title": {
"typography": {
"fontWeight": "700"
}
}
}
}
}

View File

@ -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": {

View File

@ -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 );

View File

@ -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']
);
}