mirror of
git://develop.git.wordpress.org/
synced 2025-04-14 00:52:00 +02:00
Editor: Fix failing unit test for i18n support in theme.json
As part of the change, I also did some code reorganization to match with how other test fixtures are handled. Follow-up [50959]. See #52991. git-svn-id: https://develop.svn.wordpress.org/trunk@50960 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
ef3da3363a
commit
987acb5954
BIN
tests/phpunit/data/languages/themes/fse-pl_PL.mo
Normal file
BIN
tests/phpunit/data/languages/themes/fse-pl_PL.mo
Normal file
Binary file not shown.
4
tests/phpunit/data/themedir1/fse/index.php
Normal file
4
tests/phpunit/data/themedir1/fse/index.php
Normal file
@ -0,0 +1,4 @@
|
||||
<?php
|
||||
/**
|
||||
* Dummy theme.
|
||||
*/
|
@ -3,14 +3,15 @@
|
||||
/**
|
||||
* Test WP_Theme_JSON_Resolver class.
|
||||
*
|
||||
* @package Gutenberg
|
||||
* @package WordPress
|
||||
* @since 5.8.0
|
||||
*/
|
||||
|
||||
class WP_Theme_JSON_Resolver_Test extends WP_UnitTestCase {
|
||||
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
$this->theme_root = realpath( __DIR__ . '/data/themedir1' );
|
||||
$this->theme_root = realpath( DIR_TESTDATA . '/themedir1' );
|
||||
|
||||
$this->orig_theme_dir = $GLOBALS['wp_theme_directories'];
|
||||
|
||||
@ -40,6 +41,9 @@ class WP_Theme_JSON_Resolver_Test extends WP_UnitTestCase {
|
||||
return 'pl_PL';
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 52991
|
||||
*/
|
||||
function test_fields_are_extracted() {
|
||||
$actual = WP_Theme_JSON_Resolver::get_fields_to_translate();
|
||||
|
||||
@ -84,9 +88,12 @@ class WP_Theme_JSON_Resolver_Test extends WP_UnitTestCase {
|
||||
$this->assertEquals( $expected, $actual );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 52991
|
||||
*/
|
||||
function test_translations_are_applied() {
|
||||
add_filter( 'locale', array( $this, 'filter_set_locale_to_polish' ) );
|
||||
load_textdomain( 'fse', realpath( __DIR__ . '/data/languages/themes/fse-pl_PL.mo' ) );
|
||||
load_textdomain( 'fse', realpath( DIR_TESTDATA . '/languages/themes/fse-pl_PL.mo' ) );
|
||||
|
||||
switch_theme( 'fse' );
|
||||
|
||||
@ -131,6 +138,9 @@ class WP_Theme_JSON_Resolver_Test extends WP_UnitTestCase {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 52991
|
||||
*/
|
||||
function test_switching_themes_recalculates_data() {
|
||||
// By default, the theme for unit tests is "default",
|
||||
// which doesn't have theme.json support.
|
@ -3,11 +3,15 @@
|
||||
/**
|
||||
* Test WP_Theme_JSON class.
|
||||
*
|
||||
* @package Gutenberg
|
||||
* @package WordPress
|
||||
* @since 5.8.0
|
||||
*/
|
||||
|
||||
class WP_Theme_JSON_Test extends WP_UnitTestCase {
|
||||
|
||||
/**
|
||||
* @ticket 52991
|
||||
*/
|
||||
function test_get_settings() {
|
||||
$theme_json = new WP_Theme_JSON(
|
||||
array(
|
||||
@ -52,6 +56,9 @@ class WP_Theme_JSON_Test extends WP_UnitTestCase {
|
||||
$this->assertEqualSetsWithIndex( $expected, $actual );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 52991
|
||||
*/
|
||||
public function test_merge_incoming_data() {
|
||||
$initial = array(
|
||||
'version' => WP_Theme_JSON::LATEST_SCHEMA,
|
||||
@ -259,6 +266,9 @@ class WP_Theme_JSON_Test extends WP_UnitTestCase {
|
||||
$this->assertEqualSetsWithIndex( $expected, $actual );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 52991
|
||||
*/
|
||||
function test_get_from_editor_settings() {
|
||||
$input = array(
|
||||
'disableCustomColors' => true,
|
||||
@ -332,6 +342,9 @@ class WP_Theme_JSON_Test extends WP_UnitTestCase {
|
||||
$this->assertEqualSetsWithIndex( $expected, $actual );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 52991
|
||||
*/
|
||||
function test_get_editor_settings_no_theme_support() {
|
||||
$input = array(
|
||||
'__unstableEnableFullSiteEditingBlocks' => false,
|
||||
@ -384,6 +397,9 @@ class WP_Theme_JSON_Test extends WP_UnitTestCase {
|
||||
$this->assertEqualSetsWithIndex( $expected, $actual );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 52991
|
||||
*/
|
||||
function test_get_editor_settings_blank() {
|
||||
$expected = array(
|
||||
'version' => WP_Theme_JSON::LATEST_SCHEMA,
|
||||
@ -394,6 +410,9 @@ class WP_Theme_JSON_Test extends WP_UnitTestCase {
|
||||
$this->assertEqualSetsWithIndex( $expected, $actual );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 52991
|
||||
*/
|
||||
function test_get_editor_settings_custom_units_can_be_disabled() {
|
||||
add_theme_support( 'custom-units', array() );
|
||||
$input = get_default_block_editor_settings();
|
||||
@ -408,6 +427,9 @@ class WP_Theme_JSON_Test extends WP_UnitTestCase {
|
||||
$this->assertEqualSetsWithIndex( $expected, $actual['settings']['spacing'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 52991
|
||||
*/
|
||||
function test_get_editor_settings_custom_units_can_be_enabled() {
|
||||
add_theme_support( 'custom-units' );
|
||||
$input = get_default_block_editor_settings();
|
||||
@ -422,6 +444,9 @@ class WP_Theme_JSON_Test extends WP_UnitTestCase {
|
||||
$this->assertEqualSetsWithIndex( $expected, $actual['settings']['spacing'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 52991
|
||||
*/
|
||||
function test_get_editor_settings_custom_units_can_be_filtered() {
|
||||
add_theme_support( 'custom-units', 'rem', 'em' );
|
||||
$input = get_default_block_editor_settings();
|
@ -161,6 +161,7 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase {
|
||||
'Internationalized Theme',
|
||||
'camelCase',
|
||||
'REST Theme',
|
||||
'FSE Theme',
|
||||
);
|
||||
|
||||
sort( $theme_names );
|
||||
|
Loading…
x
Reference in New Issue
Block a user