mirror of
git://develop.git.wordpress.org/
synced 2025-03-13 16:39:48 +01:00
Tests: Increase test coverage for WP_Theme_JSON_Resolver
.
This commit adds a unit test to check that `WP_Theme_JSON_Resolver::get_theme_data()` returns a `WP_Theme_JSON` object, and that an `add_theme_support()` call overrides the settings from `theme.json`. Follow-up to [54443], [54493]. Props cbravobernal. Fixes #56835. git-svn-id: https://develop.svn.wordpress.org/trunk@54630 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
4ef9c315c5
commit
313ebd3162
@ -693,4 +693,27 @@ class Tests_Theme_wpThemeJsonResolver extends WP_UnitTestCase {
|
||||
$this->assertIsArray( $post2 );
|
||||
$this->assertSameSets( array(), $post2 );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 56835
|
||||
* @covers WP_Theme_JSON_Resolver::get_theme_data
|
||||
*/
|
||||
function test_get_theme_data_theme_supports_overrides_theme_json() {
|
||||
// Test that get_theme_data() returns a WP_Theme_JSON object.
|
||||
$theme_json_resolver = new WP_Theme_JSON_Resolver();
|
||||
$theme_data = $theme_json_resolver->get_theme_data();
|
||||
$this->assertInstanceOf( 'WP_Theme_JSON', $theme_data, 'Theme data should be an instance of WP_Theme_JSON.' );
|
||||
|
||||
// Test that wp_theme_json_data_theme filter has been called.
|
||||
$this->assertGreaterThan( 0, did_filter( 'wp_theme_json_data_default' ), 'The filter "theme_json_default" should fire.' );
|
||||
|
||||
// Test that data from theme.json is backfilled from existing theme supports.
|
||||
$previous_settings = $theme_data->get_settings();
|
||||
$previous_line_height = $previous_settings['typography']['lineHeight'];
|
||||
$this->assertFalse( $previous_line_height, 'lineHeight setting from theme.json should be false.' );
|
||||
add_theme_support( 'custom-line-height' );
|
||||
$current_settings = $theme_json_resolver->get_theme_data()->get_settings();
|
||||
$line_height = $current_settings['typography']['lineHeight'];
|
||||
$this->assertTrue( $line_height, 'lineHeight setting after add_theme_support() should be true.' );
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user